Project

General

Profile

RE: PIN mux details and modifications ยป baseboard-mityarm335x-devkit.c

Raja Vankam, 04/26/2012 04:08 PM

 
1
/*
2
 * Critical Link MityARM-335x SoM Development Kit Baseboard Initialization File
3
 *
4
 * Someday... Someday... most of this should be replaced with device tree....
5
 */
6
#include <linux/kernel.h>
7
#include <linux/init.h>
8
#include <linux/clk.h>
9
#include <linux/err.h>
10
#include <linux/phy.h>
11
#include <linux/usb/musb.h>
12
#include <linux/dma-mapping.h>
13
#include <linux/spi/spi.h>
14

    
15
#include <video/da8xx-fb.h>
16
#include <plat/lcdc.h> /* uhhggg... */
17
#include <plat/mmc.h>
18
#include <plat/usb.h>
19
#include <plat/omap_device.h>
20
#include <plat/mcspi.h>
21
#include <plat/i2c.h>
22

    
23
#include <asm/hardware/asp.h>
24

    
25
#include "mux.h"
26
#include "hsmmc.h"
27
#include "devices.h"
28

    
29
#define BASEBOARD_NAME "MityARM-335x DevKit"
30
/* Vitesse 8601 register defs we need... */
31
#define VSC8601_PHY_ID   (0x00070420)
32
#define VSC8601_PHY_MASK (0xFFFFFFFC)
33
#define MII_EXTPAGE		 (0x1F)
34
#define RGMII_SKEW		 (0x1C)
35

    
36

    
37
/* TODO - refactor all the pinmux stuff for all board files to use */
38
#define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
39

    
40
struct pinmux_config {
41
	const char	*muxname;
42
	int		val;
43
};
44

    
45

    
46
#define setup_pin_mux(pin_mux) \
47
{ \
48
	int i = 0; \
49
	for (; pin_mux[i].muxname != NULL; i++) \
50
		omap_mux_init_signal(pin_mux[i].muxname, pin_mux[i].val); \
51
}
52

    
53
static struct pinmux_config rgmii2_pin_mux[] = {
54
	{"gpmc_a0.rgmii2_tctl",	AM33XX_PIN_OUTPUT},
55
	{"gpmc_a1.rgmii2_rctl",	AM33XX_PIN_INPUT_PULLDOWN},
56
	{"gpmc_a2.rgmii2_td3",	AM33XX_PIN_OUTPUT},
57
	{"gpmc_a3.rgmii2_td2",	AM33XX_PIN_OUTPUT},
58
	{"gpmc_a4.rgmii2_td1",	AM33XX_PIN_OUTPUT},
59
	{"gpmc_a5.rgmii2_td0",	AM33XX_PIN_OUTPUT},
60
	{"gpmc_a6.rgmii2_tclk",	AM33XX_PIN_OUTPUT},
61
	{"gpmc_a7.rgmii2_rclk",	AM33XX_PIN_INPUT_PULLDOWN},
62
	{"gpmc_a8.rgmii2_rd3",	AM33XX_PIN_INPUT_PULLDOWN},
63
	{"gpmc_a9.rgmii2_rd2",	AM33XX_PIN_INPUT_PULLDOWN},
64
	{"gpmc_a10.rgmii2_rd1",	AM33XX_PIN_INPUT_PULLDOWN},
65
	{"gpmc_a11.rgmii2_rd0",	AM33XX_PIN_INPUT_PULLDOWN},
66
	{"mdio_data.mdio_data",	AM33XX_PIN_INPUT_PULLUP},
67
	{"mdio_clk.mdio_clk",	AM33XX_PIN_OUTPUT_PULLUP},
68
	{NULL, 0}
69
};
70

    
71
static struct pinmux_config lcdc_pin_mux[] = {
72
	/*{"lcd_data0.lcd_data0",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},*//*Change*/
73
{"lcd_data0.gpio2_6",		AM33XX_PIN_OUTPUT},
74
	{"lcd_data1.lcd_data1",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
75
	{"lcd_data2.lcd_data2",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
76
	{"lcd_data3.lcd_data3",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
77
	{"lcd_data4.lcd_data4",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
78
	{"lcd_data5.lcd_data5",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
79
	{"lcd_data6.lcd_data6",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
80
	{"lcd_data7.lcd_data7",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
81
	{"lcd_data8.lcd_data8",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
82
	{"lcd_data9.lcd_data9",		AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
83
	{"lcd_data10.lcd_data10",	AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
84
	{"lcd_data11.gpio0_8",	AM33XX_PIN_OUTPUT/*| AM33XX_PULL_DISA*/},/*Change*/
85
	{"lcd_data12.lcd_data12",	AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
86
	{"lcd_data13.lcd_data13",	AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
87
	{"lcd_data14.lcd_data14",	AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
88
	{"lcd_data15.lcd_data15",	AM33XX_PIN_OUTPUT | AM33XX_PULL_DISA},
89
	{"lcd_vsync.lcd_vsync",		AM33XX_PIN_OUTPUT},
90
	{"lcd_hsync.lcd_hsync",		AM33XX_PIN_OUTPUT},
91
	{"lcd_pclk.lcd_pclk",		AM33XX_PIN_OUTPUT},
92
	{"lcd_ac_bias_en.lcd_ac_bias_en", AM33XX_PIN_OUTPUT},
93
	{NULL, 0}
94
};
95

    
96
static struct pinmux_config mmc0_pin_mux[] = {
97
	{"mmc0_dat3.mmc0_dat3", AM33XX_PIN_INPUT_PULLUP},
98
	{"mmc0_dat2.mmc0_dat2", AM33XX_PIN_INPUT_PULLUP},
99
	{"mmc0_dat1.mmc0_dat1", AM33XX_PIN_INPUT_PULLUP},
100
	{"mmc0_dat0.mmc0_dat0", AM33XX_PIN_INPUT_PULLUP},
101
	{"mmc0_clk.mmc0_clk",   AM33XX_PIN_INPUT_PULLUP},
102
	{"mmc0_cmd.mmc0_cmd",   AM33XX_PIN_INPUT_PULLUP},
103
	{"mii1_txen.gpio3_3",	AM33XX_PIN_INPUT_PULLUP}, /* SD Card Detect */
104
	{"mii1_col.gpio3_0",	AM33XX_PIN_INPUT_PULLUP}, /* SD Write Protect */
105
	{NULL, 0}
106
};
107

    
108
static struct pinmux_config can_pin_mux[] = {
109
	/*{"uart1_rxd.d_can1_tx", AM33XX_PULL_ENBL},
110
	{"uart1_txd.d_can1_rx", AM33XX_PIN_INPUT_PULLUP},
111
	{"mii1_txd3.d_can0_tx", AM33XX_PULL_ENBL},
112
	{"mii1_txd2.d_can0_rx", AM33XX_PIN_INPUT_PULLUP},*/
113
	{"uart1_rxd.gpio0_14", AM33XX_PIN_OUTPUT},
114
	{"uart1_txd.gpio0_15", AM33XX_PIN_OUTPUT},
115
	{"mii1_txd3.gpio0_16", AM33XX_PIN_OUTPUT},
116
	{"mii1_txd2.gpio0_17", AM33XX_PIN_OUTPUT},
117
	{NULL, 0}
118
};
119

    
120
static struct pinmux_config expansion_pin_mux[] = {
121
	{"uart0_ctsn.uart4_rxd", AM33XX_PIN_INPUT_PULLUP},/* Exp0 RX */
122
	{"uart0_rtsn.uart4_txd", AM33XX_PULL_ENBL},		/* Exp0 TX */
123
	{"mii1_rxd3.uart3_rxd", AM33XX_PIN_INPUT_PULLUP},/* Exp1 RX */
124
	{"mii1_rxd2.uart3_txd", AM33XX_PULL_ENBL},		/* Exp1 TX */
125
	{NULL, 0}
126
};
127

    
128
static struct pinmux_config usb_pin_mux[] = {
129
	{"usb0_drvvbus.usb0_drvvbus",	AM33XX_PIN_OUTPUT},
130
	{"usb1_drvvbus.usb1_drvvbus",	AM33XX_PIN_OUTPUT},
131
	{NULL, 0}
132
};
133

    
134
static struct omap2_hsmmc_info mmc_info[] __initdata = {
135
	{
136
		.mmc		= 1,
137
		.caps		= MMC_CAP_4_BIT_DATA,
138
		.gpio_cd	= GPIO_TO_PIN(3, 3),
139
		.gpio_wp	= GPIO_TO_PIN(3, 0),
140
		.ocr_mask	= MMC_VDD_32_33 | MMC_VDD_33_34,
141
	},
142
	{}
143
};
144

    
145
static __init void baseboard_setup_expansion(void)
146
{
147
	setup_pin_mux(expansion_pin_mux);
148
}
149

    
150
static __init void baseboard_setup_can(void)
151
{
152
	setup_pin_mux(can_pin_mux);
153

    
154
	/*am33xx_d_can_init(0);
155
	am33xx_d_can_init(1);*/
156
}
157

    
158
static struct omap_musb_board_data board_data = {
159
	.interface_type	= MUSB_INTERFACE_ULPI,
160
	.mode           = MUSB_OTG,
161
	.power		= 500,
162
	.instances	= 1,
163
};
164

    
165
static __init void baseboard_setup_usb(void)
166
{
167
	setup_pin_mux(usb_pin_mux);
168
	usb_musb_init(&board_data);
169
}
170

    
171
static __init void baseboard_setup_mmc(void)
172
{
173
	/* pin mux */
174
	setup_pin_mux(mmc0_pin_mux);
175

    
176
	/* configure mmc */
177
	omap2_hsmmc_init(mmc_info);
178
}
179

    
180
static const struct display_panel disp_panel = {
181
	WVGA,		/* panel_type */
182
	32,		/* max_bpp */
183
	16,		/* min_bpp */
184
	COLOR_ACTIVE,	/* panel_shade */
185
};
186

    
187
static struct lcd_ctrl_config dvi_cfg = {
188
	.p_disp_panel		= &disp_panel,
189
	.ac_bias		= 255,
190
	.ac_bias_intrpt		= 0,
191
	.dma_burst_sz		= 16,
192
	.bpp			= 16,
193
	.fdd			= 0x80,
194
	.tft_alt_mode		= 0,
195
	.stn_565_mode		= 0,
196
	.mono_8bit_mode		= 0,
197
	.invert_line_clock	= 1,
198
	.invert_frm_clock	= 1,
199
	.sync_edge		= 0,
200
	.sync_ctrl		= 1,
201
	.raster_order		= 0,
202
};
203

    
204
/* TODO - should really update driver to support VESA mode timings... */
205
struct da8xx_lcdc_platform_data dvi_pdata = {
206
	.manu_name		= "VESA",
207
	.controller_data	= &dvi_cfg,
208
	.type			= "800x600",
209
};
210

    
211
static __init void baseboard_setup_dvi(void)
212
{
213
	struct clk *disp_pll;
214

    
215
	/* pinmux */
216
	setup_pin_mux(lcdc_pin_mux);
217

    
218
	/* add I2C1 device entry *//*Change*/
219

    
220
	/* TODO - really need to modify da8xx driver to support mating to the
221
	 * TFP410 and tweaking settings at the driver level... need to stew on
222
	 * this..
223
	 */
224

    
225
	/* configure / enable LCDC */
226
	/*disp_pll = clk_get(NULL, "dpll_disp_ck");
227
	if (IS_ERR(disp_pll)) {
228
		pr_err("Connect get disp_pll\n");
229
		return;
230
	}
231

    
232
	if (clk_set_rate(disp_pll, 300000000)) {
233
		pr_warning("%s: Unable to initialize display PLL.\n",
234
			__func__);
235
		goto out;
236
	}*/
237
pr_info("MODIFIED LCD****...\n");
238
	/*if (am33xx_register_lcdc(&dvi_pdata))
239
		pr_warning("%s: Unable to register LCDC device.\n",
240
			__func__);*/
241

    
242
	/* backlight */
243
out:
244
	clk_put(disp_pll);
245
}
246

    
247
/* Module pin mux for mcasp1 */
248
static struct pinmux_config mcasp1_pin_mux[] = {
249
	{"mcasp0_aclkr.mcasp1_aclkx", AM33XX_PIN_INPUT_PULLDOWN},
250
	{"mcasp0_fsr.mcasp1_fsx", AM33XX_PIN_INPUT_PULLDOWN},
251
	{"mcasp0_axr1.mcasp1_axr0", AM33XX_PIN_OUTPUT},
252
	{"mcasp0_ahclkx.mcasp1_axr1", AM33XX_PIN_INPUT_PULLDOWN},
253
	{"mii1_rxd0.mcasp1_ahclkr", AM33XX_PIN_INPUT_PULLDOWN},
254
	{"mii1_refclk.mcasp1_ahclkx", AM33XX_PIN_INPUT_PULLDOWN},
255
	{NULL, 0},
256
};
257

    
258
static struct pinmux_config spi0_pin_mux[] = {
259
	{"spi0_cs0.spi0_cs0", AM33XX_PIN_OUTPUT_PULLUP},
260
	{"spi0_cs1.spi0_cs1", AM33XX_PIN_OUTPUT_PULLUP},
261
	{"spi0_sclk.spi0_sclk", AM33XX_PIN_OUTPUT_PULLUP},
262
	{"spi0_d0.spi0_d0", AM33XX_PIN_OUTPUT},
263
	{"spi0_d1.spi0_d1", AM33XX_PIN_INPUT_PULLUP},
264
	{NULL, 0},
265
};
266

    
267
static u8 am335x_iis_serializer_direction[] = {
268
	TX_MODE,	RX_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
269
	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
270
	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
271
	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
272
};
273

    
274
static struct snd_platform_data baseboard_snd_data = {
275
	.tx_dma_offset	= 0x46400000,	/* McASP1 */
276
	.rx_dma_offset	= 0x46400000,
277
	.op_mode	= DAVINCI_MCASP_IIS_MODE,
278
	.num_serializer	= ARRAY_SIZE(am335x_iis_serializer_direction),
279
	.tdm_slots	= 2,
280
	.serial_dir	= am335x_iis_serializer_direction,
281
	.asp_chan_q	= EVENTQ_2,
282
	.version	= MCASP_VERSION_3,
283
	.txnumevt	= 1,
284
	.rxnumevt	= 1,
285
};
286

    
287
static struct omap2_mcspi_device_config spi0_ctlr_data = {
288
	.turbo_mode = 0,
289
	.single_channel = 0,
290
	.d0_is_mosi = 1,
291
};
292

    
293
static struct spi_board_info baseboard_spi0_slave_info[] = {
294
	{
295
		.modalias	= "tlv320aic26-codec",
296
		.controller_data = &spi0_ctlr_data,
297
		.irq		= -1,
298
		.max_speed_hz	= 2000000,
299
		.bus_num	= 1,
300
		.chip_select	= 1,
301
		.mode		= SPI_MODE_1,
302
	},
303
	/* TODO -- add touchscreen connector options */
304
};
305

    
306
static __init void baseboard_setup_audio(void)
307
{
308
	pr_info("Configuring audio...\n");
309
	setup_pin_mux(mcasp1_pin_mux);
310
	setup_pin_mux(spi0_pin_mux);
311
	am335x_register_mcasp1(&baseboard_snd_data);
312
	spi_register_board_info(baseboard_spi0_slave_info,
313
			ARRAY_SIZE(baseboard_spi0_slave_info));
314
}
315

    
316
static struct pinmux_config i2c0_pin_mux[] = {
317
	{"i2c0_sda.i2c0_sda",	AM33XX_SLEWCTRL_SLOW | AM33XX_PULL_ENBL |
318
				AM33XX_INPUT_EN | AM33XX_PIN_OUTPUT},
319
	{"i2c0_scl.i2c0_scl",	AM33XX_SLEWCTRL_SLOW | AM33XX_PULL_ENBL |
320
				AM33XX_INPUT_EN | AM33XX_PIN_OUTPUT},
321
	{NULL, 0},
322
};
323

    
324
static void __init baseboard_i2c0_init(void)
325
{
326
	setup_pin_mux(i2c0_pin_mux);
327
	omap_register_i2c_bus(1, 100, NULL, 0);
328
}
329

    
330
/* fixup for the Vitesse 8601 PHY on the MityARM335x dev kit.
331
 * We need to adjust the recv clock skew to recenter the data eye.
332
 */
333
static int am335x_vsc8601_phy_fixup(struct phy_device *phydev)
334
{
335
	unsigned int val;
336

    
337
	pr_info("am335x_vsc8601_phy_fixup %x here addr = %d\n",
338
			phydev->phy_id, phydev->addr);
339

    
340
	/* skew control is in extended register set */
341
	if (phy_write(phydev,  MII_EXTPAGE, 1) < 0) {
342
		pr_err("Error enabling extended PHY regs\n");
343
		return 1;
344
	}
345
	/* read the skew */
346
	val = phy_read(phydev, RGMII_SKEW);
347
	if (val < 0) {
348
		pr_err("Error reading RGMII skew reg\n");
349
		return val;
350
	}
351
	val &= 0x0FFF; /* clear skew values */
352
	val |= 0x3000; /* 0 Tx skew, 2.0ns Rx skew */
353
	if (phy_write(phydev, RGMII_SKEW, val) < 0) {
354
		pr_err("failed to write RGMII_SKEW\n");
355
		return 1;
356
	}
357
	/* disable the extended page access */
358
	if (phy_write(phydev, MII_EXTPAGE, 0) < 0) {
359
		pr_err("Error disabling extended PHY regs\n");
360
		return 1;
361
	}
362
	return 0;
363
}
364

    
365
static __init void baseboard_setup_enet(void)
366
{
367
	/* pinmux */
368
	setup_pin_mux(rgmii2_pin_mux);
369

    
370
	/* network configuration done in SOM code */
371
	/* PHY address setup? */
372
	/* Register PHY fixup to adjust rx clock skew */
373
	phy_register_fixup_for_uid(VSC8601_PHY_ID,
374
				VSC8601_PHY_MASK,
375
				am335x_vsc8601_phy_fixup);
376
}
377

    
378
static __init int baseboard_init(void)
379
{
380
	pr_info("%s [%s]...\n", __func__, BASEBOARD_NAME);
381

    
382
	baseboard_setup_enet();
383

    
384
	baseboard_setup_mmc();
385

    
386
	baseboard_setup_usb();
387

    
388
	baseboard_setup_expansion();
389

    
390
	baseboard_setup_expansion();
391

    
392
	baseboard_setup_dvi();
393

    
394
	baseboard_setup_can();
395

    
396
	//baseboard_setup_audio();/*Change*/
397

    
398
	baseboard_i2c0_init();
399

    
400
	return 0;
401
}
402
arch_initcall_sync(baseboard_init);
403

    
    (1-1/1)
    Go to top
    Add picture from clipboard (Maximum size: 1 GB)