Project

General

Profile

RE: GPIO toggling/chattering while performing NAND read. ยป mux.c

Srinivasa Wunnimani, 03/27/2020 07:55 AM

 
1
/*
2
 * mux.c
3
 *
4
 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License as
8
 * published by the Free Software Foundation version 2.
9
 *
10
 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11
 * kind, whether express or implied; without even the implied warranty
12
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 */
15
#include <config.h>
16
#include "common_def.h"
17
#include <asm/arch/hardware.h>
18
#include <asm/arch/mux.h>
19

    
20
#define DEV_ON_BASEBOARD       0
21
#define DEV_ON_DGHTR_BRD       1
22

    
23
struct evm_pin_mux {
24
        struct module_pin_mux *mod_pin_mux;
25
	    unsigned short profile;
26
		};
27

    
28
static struct module_pin_mux uart0_pin_mux[] = {
29
	{OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* UART0_RXD */
30
	{OFFSET(uart0_txd), (MODE(0) | PULLUDEN)},		/* UART0_TXD */
31
	{-1},
32
};
33

    
34
#ifdef CONFIG_NAND
35
static struct module_pin_mux nand_pin_mux[] = {
36
	{OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD0 */
37
	{OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD1 */
38
	{OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD2 */
39
	{OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD3 */
40
	{OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD4 */
41
	{OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD5 */
42
	{OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD6 */
43
	{OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)},	/* NAND AD7 */
44
	{OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */
45
	{OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)},	/* NAND_WPN */
46
	{OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)},	/* NAND_CS0 */
47
	{OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */
48
	{OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)},	/* NAND_OE */
49
	{OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)},	/* NAND_WEN */
50
	{OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)},	/* NAND_BE_CLE */
51
	{-1},
52
};
53
#endif
54

    
55
static struct module_pin_mux i2c0_pin_mux[] = {
56
	{OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)},	/* I2C_DATA */
57
	{OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)},	/* I2C_SCLK */
58
	{-1},
59
};
60

    
61
static struct module_pin_mux i2c1_pin_mux[] = {
62
	{OFFSET(mii1_crs), (MODE(3) | RXACTIVE | PULLUDEN | SLEWCTRL)},	/* I2C_DATA */
63
	{OFFSET(mii1_rxerr), (MODE(3) | RXACTIVE | PULLUDEN | SLEWCTRL)},	/* I2C_SCLK */
64
	{-1},
65
};
66

    
67

    
68
static struct module_pin_mux i2c2_pin_mux[] = {
69
	{OFFSET(uart1_ctsn), (MODE(3) | RXACTIVE | PULLUDEN | SLEWCTRL)},	/* I2C_DATA */
70
	{OFFSET(uart1_rtsn), (MODE(3) | RXACTIVE | PULLUDEN | SLEWCTRL)},	/* I2C_SCLK */
71
	{-1},
72
};
73

    
74
#ifndef CONFIG_NO_ETH
75

    
76
static struct module_pin_mux rgmii1_pin_mux[] = {
77
	{OFFSET(mii1_txen), MODE(2)},			/* RGMII1_TCTL */
78
	{OFFSET(mii1_rxdv), MODE(2) | RXACTIVE},	/* RGMII1_RCTL */
79
	{OFFSET(mii1_txd3), MODE(2)},			/* RGMII1_TD3 */
80
	{OFFSET(mii1_txd2), MODE(2)},			/* RGMII1_TD2 */
81
	{OFFSET(mii1_txd1), MODE(2)},			/* RGMII1_TD1 */
82
	{OFFSET(mii1_txd0), MODE(2)},			/* RGMII1_TD0 */
83
	{OFFSET(mii1_txclk), MODE(2)},			/* RGMII1_TCLK */
84
	{OFFSET(mii1_rxclk), MODE(2) | RXACTIVE},	/* RGMII1_RCLK */
85
	{OFFSET(mii1_rxd3), MODE(2) | RXACTIVE},	/* RGMII1_RD3 */
86
	{OFFSET(mii1_rxd2), MODE(2) | RXACTIVE},	/* RGMII1_RD2 */
87
	{OFFSET(mii1_rxd1), MODE(2) | RXACTIVE},	/* RGMII1_RD1 */
88
	{OFFSET(mii1_rxd0), MODE(2) | RXACTIVE},	/* RGMII1_RD0 */
89
	{OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
90
	{OFFSET(mdio_clk), MODE(0) | PULLUP_EN},	/* MDIO_CLK */
91
	{-1},
92
};
93

    
94
static struct module_pin_mux rgmii2_pin_mux[] = {
95
	{OFFSET(gpmc_a0), MODE(2)},			/* RGMII2_TCTL */
96
	{OFFSET(gpmc_a1), MODE(2) | RXACTIVE},		/* RGMII2_RCTL */
97
	{OFFSET(gpmc_a2), MODE(2)},			/* RGMII2_TD3 */
98
	{OFFSET(gpmc_a3), MODE(2)},			/* RGMII2_TD2 */
99
	{OFFSET(gpmc_a4), MODE(2)},			/* RGMII2_TD1 */
100
	{OFFSET(gpmc_a5), MODE(2)},			/* RGMII2_TD0 */
101
	{OFFSET(gpmc_a6), MODE(2)},			/* RGMII2_TCLK */
102
	{OFFSET(gpmc_a7), MODE(2) | RXACTIVE},		/* RGMII2_RCLK */
103
	{OFFSET(gpmc_a8), MODE(2) | RXACTIVE},		/* RGMII2_RD3 */
104
	{OFFSET(gpmc_a9), MODE(2) | RXACTIVE},		/* RGMII2_RD2 */
105
	{OFFSET(gpmc_a10), MODE(2) | RXACTIVE},		/* RGMII2_RD1 */
106
	{OFFSET(gpmc_a11), MODE(2) | RXACTIVE},		/* RGMII2_RD0 */
107
	{OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
108
	{OFFSET(mdio_clk), MODE(0) | PULLUP_EN},	/* MDIO_CLK */
109
        {OFFSET(mii1_rxclk), MODE(7) | PULLUP_EN | PULLUDEN},	/* PHY RESET N on MITYARM3359 EVM */
110
	{-1},
111
};
112

    
113
// UNUSED
114
//static struct module_pin_mux mii1_pin_mux[] = {
115
//	{OFFSET(mii1_rxerr), MODE(0) | RXACTIVE},	/* MII1_RXERR */
116
//	{OFFSET(mii1_txen), MODE(0)},			/* MII1_TXEN */
117
//	{OFFSET(mii1_rxdv), MODE(0) | RXACTIVE},	/* MII1_RXDV */
118
//	{OFFSET(mii1_txd3), MODE(0)},			/* MII1_TXD3 */
119
//	{OFFSET(mii1_txd2), MODE(0)},			/* MII1_TXD2 */
120
//	{OFFSET(mii1_txd1), MODE(0)},			/* MII1_TXD1 */
121
//	{OFFSET(mii1_txd0), MODE(0)},			/* MII1_TXD0 */
122
//	{OFFSET(mii1_txclk), MODE(0) | RXACTIVE},	/* MII1_TXCLK */
123
//	{OFFSET(mii1_rxclk), MODE(0) | RXACTIVE},	/* MII1_RXCLK */
124
//	{OFFSET(mii1_rxd3), MODE(0) | RXACTIVE},	/* MII1_RXD3 */
125
//	{OFFSET(mii1_rxd2), MODE(0) | RXACTIVE},	/* MII1_RXD2 */
126
//	{OFFSET(mii1_rxd1), MODE(0) | RXACTIVE},	/* MII1_RXD1 */
127
//	{OFFSET(mii1_rxd0), MODE(0) | RXACTIVE},	/* MII1_RXD0 */
128
//	{OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
129
//	{OFFSET(mdio_clk), MODE(0) | PULLUP_EN},	/* MDIO_CLK */
130
//	{-1},
131
//};
132
//
133
//static struct module_pin_mux rmii1_pin_mux[] = {
134
//   {OFFSET(mii1_crs), MODE(1) | RXACTIVE},     /* RMII1_CRS */
135
//   {OFFSET(mii1_rxerr), MODE(1) | RXACTIVE},   /* RMII1_RXERR */
136
//   {OFFSET(mii1_txen), MODE(1)},           /* RMII1_TXEN */
137
//   {OFFSET(mii1_txd1), MODE(1)},           /* RMII1_TXD1 */
138
//   {OFFSET(mii1_txd0), MODE(1)},           /* RMII1_TXD0 */
139
//   {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE},    /* RMII1_RXD1 */
140
//   {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE},    /* RMII1_RXD0 */
141
//   {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
142
//   {OFFSET(mdio_clk), MODE(0) | PULLUP_EN},    /* MDIO_CLK */
143
//   {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */
144
//   {-1},
145
//};
146
#endif
147

    
148
#ifdef CONFIG_MMC
149
static struct module_pin_mux mmc0_pin_mux[] = {
150
	{OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)},	/* MMC0_DAT3 */
151
	{OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)},	/* MMC0_DAT2 */
152
	{OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)},	/* MMC0_DAT1 */
153
	{OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)},	/* MMC0_DAT0 */
154
	{OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)},	/* MMC0_CLK */
155
	{OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)},	/* MMC0_CMD */
156
#ifndef CONFIG_AM335X_TF
157
        {OFFSET(mii1_col), (MODE(7) | RXACTIVE)},		/* MMC0_WP */
158
	{OFFSET(mii1_txen), (MODE(7) | RXACTIVE | PULLUP_EN)},	/* MMC0_CD */
159
#endif /* CONFIG_AM335X_TF */
160
	{-1},
161
};
162

    
163
// UNUSED
164
//static struct module_pin_mux mmc1_pin_mux[] = {
165
//	{OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE)},	/* MMC1_DAT3 */
166
//	{OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE)},	/* MMC1_DAT2 */
167
//	{OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE)},	/* MMC1_DAT1 */
168
//	{OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE)},	/* MMC1_DAT0 */
169
//	{OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)},	/* MMC1_CLK */
170
//	{OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)},	/* MMC1_CMD */
171
//	{OFFSET(uart1_rxd), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_WP */
172
//	{OFFSET(mcasp0_fsx), (MODE(4) | RXACTIVE)},	/* MMC1_CD */
173
//	{-1},
174
//};
175
#endif
176

    
177
#ifdef CONFIG_SPI
178
static struct module_pin_mux spi0_pin_mux[] = {
179
	{OFFSET(spi0_sclk), MODE(0) | PULLUDEN | RXACTIVE},	/*SPI0_SCLK */
180
	{OFFSET(spi0_d0), MODE(0) | PULLUDEN | PULLUP_EN |
181
							RXACTIVE}, /*SPI0_D0 */
182
	{OFFSET(spi0_d1), MODE(0) | PULLUDEN |
183
							RXACTIVE}, /*SPI0_D1 */
184
	{OFFSET(spi0_cs0), MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE},	/*SPI0_CS0 */
185
	{-1},
186
};
187

    
188
static struct module_pin_mux spi1_pin_mux[] = {
189
        {OFFSET(ecap0_in_pwm0_out), MODE(4) | PULLUDEN | RXACTIVE},	/*SPI1_SCLK */
190
        {OFFSET(mcasp0_fsx), MODE(3) | PULLUDEN | PULLUP_EN |
191
                                                        RXACTIVE}, /*SPI1_D0 */
192
        {OFFSET(mcasp0_axr0), MODE(3) | PULLUDEN | RXACTIVE}, /*SPI1_D1 */
193
	{OFFSET(mcasp0_ahclkr), MODE(3) | PULLUDEN | PULLUP_EN |
194
                                                        RXACTIVE}, /*SPI1_CS0 */
195
	{-1},
196
};
197
#endif
198

    
199
/*
200
 * Update the structure with the modules present in the general purpose
201
 * board and the profiles in which the modules are present.
202
 * If the module is physically present but if it is not available
203
 * in any of the profile, then do not update it.
204
 * For eg, nand is avialable only in the profiles 0 and 1, whereas
205
 * UART0  is available in all the profiles.
206
 */
207
static struct evm_pin_mux general_purpose_evm_pin_mux[] = {
208
	{uart0_pin_mux, PROFILE_ALL},
209
	{i2c1_pin_mux, PROFILE_ALL},
210
	{i2c2_pin_mux, PROFILE_ALL},
211
#ifdef CONFIG_NAND
212
	{nand_pin_mux, PROFILE_ALL},
213
#endif
214
#ifndef CONFIG_NO_ETH
215
	{rgmii1_pin_mux, PROFILE_1},
216
	{rgmii2_pin_mux, PROFILE_0},
217
#endif
218

    
219
#ifdef CONFIG_MMC
220
	{mmc0_pin_mux, PROFILE_ALL},
221
//	{mmc1_pin_mux, PROFILE_2},
222
#endif
223
#ifdef CONFIG_SPI
224
	{spi0_pin_mux, PROFILE_0},
225
	{spi1_pin_mux, PROFILE_0},
226
#endif
227
	{0},
228
};
229

    
230

    
231
static struct evm_pin_mux *am335x_pin_mux[] = {
232
	general_purpose_evm_pin_mux,
233
};
234

    
235
/*
236
 * Check each module in the daughter board(first argument) whether it is
237
 * available in the selected profile(second argument). If the module is not
238
 * available in the selected profile, skip the corresponding configuration.
239
 */
240
static void set_evm_pin_mux(struct evm_pin_mux *pin_mux,
241
			int prof)
242
{
243
	int i;
244

    
245
	if (!pin_mux)
246
		return;
247

    
248
	for (i = 0; pin_mux[i].mod_pin_mux != 0; i++)  {
249
		if ((pin_mux[i].profile & prof) ||
250
					(prof == PROFILE_NONE)) {
251
				configure_module_pin_mux(pin_mux[i].
252
								mod_pin_mux);
253
		}
254
	}
255
}
256

    
257
void configure_evm_pin_mux(unsigned char profile)
258
{
259
	set_evm_pin_mux(am335x_pin_mux[0], profile);
260
}
261

    
262
void enable_mmc0_pin_mux(void)
263
{
264
#ifdef CONFIG_MMC
265
        configure_module_pin_mux(mmc0_pin_mux);
266
#endif
267
}
268
void enable_i2c0_pin_mux(void)
269
{
270
        configure_module_pin_mux(i2c0_pin_mux);
271
}
272

    
273
void enable_i2c1_pin_mux(void)
274
{
275
	configure_module_pin_mux(i2c1_pin_mux);
276
}
277
void enable_i2c2_pin_mux(void)
278
{
279
	configure_module_pin_mux(i2c2_pin_mux);
280
}
281

    
282
void enable_uart0_pin_mux(void)
283
{
284
	configure_module_pin_mux(uart0_pin_mux);
285
}
    (1-1/1)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)