"[PATCH] Fix leaks on /proc/{*/sched,sched_debug,timer_list,timer_stats}" and
[mmotm.git] / arch / arm / mach-davinci / board-da830-evm.c
blobbfac4372be78153195cdd96fb606359d60005499
1 /*
2 * TI DA830/OMAP L137 EVM board
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 * Derived from: arch/arm/mach-davinci/board-dm644x-evm.c
7 * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
10 * or implied.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/console.h>
15 #include <linux/interrupt.h>
16 #include <linux/gpio.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/pcf857x.h>
19 #include <linux/i2c/at24.h>
21 #include <asm/mach-types.h>
22 #include <asm/mach/arch.h>
24 #include <mach/cp_intc.h>
25 #include <mach/mux.h>
26 #include <mach/da8xx.h>
27 #include <mach/usb.h>
29 #define DA830_EVM_PHY_MASK 0x0
30 #define DA830_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
32 static struct at24_platform_data da830_evm_i2c_eeprom_info = {
33 .byte_len = SZ_256K / 8,
34 .page_size = 64,
35 .flags = AT24_FLAG_ADDR16,
36 .setup = davinci_get_mac_addr,
37 .context = (void *)0x7f00,
40 static int da830_evm_ui_expander_setup(struct i2c_client *client, int gpio,
41 unsigned ngpio, void *context)
43 gpio_request(gpio + 6, "MUX_MODE");
44 #ifdef CONFIG_DA830_UI_LCD
45 gpio_direction_output(gpio + 6, 0);
46 #else /* Must be NAND or NOR */
47 gpio_direction_output(gpio + 6, 1);
48 #endif
49 return 0;
52 static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
53 unsigned ngpio, void *context)
55 gpio_free(gpio + 6);
56 return 0;
59 static struct pcf857x_platform_data da830_evm_ui_expander_info = {
60 .gpio_base = DAVINCI_N_GPIO,
61 .setup = da830_evm_ui_expander_setup,
62 .teardown = da830_evm_ui_expander_teardown,
65 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
67 I2C_BOARD_INFO("24c256", 0x50),
68 .platform_data = &da830_evm_i2c_eeprom_info,
71 I2C_BOARD_INFO("tlv320aic3x", 0x18),
74 I2C_BOARD_INFO("pcf8574", 0x3f),
75 .platform_data = &da830_evm_ui_expander_info,
79 static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
80 .bus_freq = 100, /* kHz */
81 .bus_delay = 0, /* usec */
85 * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
87 #define ON_BD_USB_DRV GPIO_TO_PIN(1, 15)
88 #define ON_BD_USB_OVC GPIO_TO_PIN(2, 4)
90 static const short da830_evm_usb11_pins[] = {
91 DA830_GPIO1_15, DA830_GPIO2_4,
95 static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
97 static int da830_evm_usb_set_power(unsigned port, int on)
99 gpio_set_value(ON_BD_USB_DRV, on);
100 return 0;
103 static int da830_evm_usb_get_power(unsigned port)
105 return gpio_get_value(ON_BD_USB_DRV);
108 static int da830_evm_usb_get_oci(unsigned port)
110 return !gpio_get_value(ON_BD_USB_OVC);
113 static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
115 static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
117 int irq = gpio_to_irq(ON_BD_USB_OVC);
118 int error = 0;
120 if (handler != NULL) {
121 da830_evm_usb_ocic_handler = handler;
123 error = request_irq(irq, da830_evm_usb_ocic_irq, IRQF_DISABLED |
124 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
125 "OHCI over-current indicator", NULL);
126 if (error)
127 printk(KERN_ERR "%s: could not request IRQ to watch "
128 "over-current indicator changes\n", __func__);
129 } else
130 free_irq(irq, NULL);
132 return error;
135 static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
136 .set_power = da830_evm_usb_set_power,
137 .get_power = da830_evm_usb_get_power,
138 .get_oci = da830_evm_usb_get_oci,
139 .ocic_notify = da830_evm_usb_ocic_notify,
141 /* TPS2065 switch @ 5V */
142 .potpgt = (3 + 1) / 2, /* 3 ms max */
145 static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
147 da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1);
148 return IRQ_HANDLED;
151 static __init void da830_evm_usb_init(void)
153 u32 cfgchip2;
154 int ret;
157 * Set up USB clock/mode in the CFGCHIP2 register.
158 * FYI: CFGCHIP2 is 0x0000ef00 initially.
160 cfgchip2 = __raw_readl(DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG));
162 /* USB2.0 PHY reference clock is 24 MHz */
163 cfgchip2 &= ~CFGCHIP2_REFFREQ;
164 cfgchip2 |= CFGCHIP2_REFFREQ_24MHZ;
167 * Select internal reference clock for USB 2.0 PHY
168 * and use it as a clock source for USB 1.1 PHY
169 * (this is the default setting anyway).
171 cfgchip2 &= ~CFGCHIP2_USB1PHYCLKMUX;
172 cfgchip2 |= CFGCHIP2_USB2PHYCLKMUX;
174 __raw_writel(cfgchip2, DA8XX_SYSCFG_VIRT(DA8XX_CFGCHIP2_REG));
176 ret = da8xx_pinmux_setup(da830_evm_usb11_pins);
177 if (ret) {
178 pr_warning("%s: USB 1.1 PinMux setup failed: %d\n",
179 __func__, ret);
180 return;
183 ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV");
184 if (ret) {
185 printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
186 "power control: %d\n", __func__, ret);
187 return;
189 gpio_direction_output(ON_BD_USB_DRV, 0);
191 ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC");
192 if (ret) {
193 printk(KERN_ERR "%s: failed to request GPIO for USB 1.1 port "
194 "over-current indicator: %d\n", __func__, ret);
195 return;
197 gpio_direction_input(ON_BD_USB_OVC);
199 ret = da8xx_register_usb11(&da830_evm_usb11_pdata);
200 if (ret)
201 pr_warning("%s: USB 1.1 registration failed: %d\n",
202 __func__, ret);
205 static struct davinci_uart_config da830_evm_uart_config __initdata = {
206 .enabled_uarts = 0x7,
209 static const short da830_evm_mcasp1_pins[] = {
210 DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1,
211 DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5,
212 DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10,
213 DA830_AXR1_11,
217 static u8 da830_iis_serializer_direction[] = {
218 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
219 INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE,
220 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
223 static struct snd_platform_data da830_evm_snd_data = {
224 .tx_dma_offset = 0x2000,
225 .rx_dma_offset = 0x2000,
226 .op_mode = DAVINCI_MCASP_IIS_MODE,
227 .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
228 .tdm_slots = 2,
229 .serial_dir = da830_iis_serializer_direction,
230 .eventq_no = EVENTQ_0,
231 .version = MCASP_VERSION_2,
232 .txnumevt = 1,
233 .rxnumevt = 1,
237 * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS.
239 static const short da830_evm_mmc_sd_pins[] = {
240 DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2,
241 DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5,
242 DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK,
243 DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2,
247 static int da830_evm_mmc_get_ro(int index)
249 int val, status, gpio_num = 33;
251 status = gpio_request(gpio_num, "MMC WP\n");
252 if (status < 0) {
253 pr_warning("%s can not open GPIO %d\n", __func__, gpio_num);
254 return 0;
256 gpio_direction_input(gpio_num);
257 val = gpio_get_value(gpio_num);
258 gpio_free(gpio_num);
259 return val;
262 static struct davinci_mmc_config da830_evm_mmc_config = {
263 .get_ro = da830_evm_mmc_get_ro,
264 .wires = 4,
265 .version = MMC_CTLR_VERSION_2,
268 static __init void da830_evm_init(void)
270 struct davinci_soc_info *soc_info = &davinci_soc_info;
271 int ret;
273 ret = da8xx_register_edma();
274 if (ret)
275 pr_warning("da830_evm_init: edma registration failed: %d\n",
276 ret);
278 ret = da8xx_pinmux_setup(da830_i2c0_pins);
279 if (ret)
280 pr_warning("da830_evm_init: i2c0 mux setup failed: %d\n",
281 ret);
283 ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata);
284 if (ret)
285 pr_warning("da830_evm_init: i2c0 registration failed: %d\n",
286 ret);
288 da830_evm_usb_init();
290 soc_info->emac_pdata->phy_mask = DA830_EVM_PHY_MASK;
291 soc_info->emac_pdata->mdio_max_freq = DA830_EVM_MDIO_FREQUENCY;
292 soc_info->emac_pdata->rmii_en = 1;
294 ret = da8xx_pinmux_setup(da830_cpgmac_pins);
295 if (ret)
296 pr_warning("da830_evm_init: cpgmac mux setup failed: %d\n",
297 ret);
299 ret = da8xx_register_emac();
300 if (ret)
301 pr_warning("da830_evm_init: emac registration failed: %d\n",
302 ret);
304 ret = da8xx_register_watchdog();
305 if (ret)
306 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
307 ret);
309 davinci_serial_init(&da830_evm_uart_config);
310 i2c_register_board_info(1, da830_evm_i2c_devices,
311 ARRAY_SIZE(da830_evm_i2c_devices));
313 ret = da8xx_pinmux_setup(da830_evm_mcasp1_pins);
314 if (ret)
315 pr_warning("da830_evm_init: mcasp1 mux setup failed: %d\n",
316 ret);
318 da8xx_register_mcasp(1, &da830_evm_snd_data);
320 ret = da8xx_pinmux_setup(da830_evm_mmc_sd_pins);
321 if (ret)
322 pr_warning("da830_evm_init: mmc/sd mux setup failed: %d\n",
323 ret);
325 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config);
326 if (ret)
327 pr_warning("da830_evm_init: mmc/sd registration failed: %d\n",
328 ret);
330 #ifdef CONFIG_DA830_UI_LCD
331 ret = da8xx_pinmux_setup(da830_lcdcntl_pins);
332 if (ret)
333 pr_warning("da830_evm_init: lcdcntl mux setup failed: %d\n",
334 ret);
336 ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
337 if (ret)
338 pr_warning("da830_evm_init: lcd setup failed: %d\n", ret);
339 #endif
341 ret = da8xx_register_rtc();
342 if (ret)
343 pr_warning("da830_evm_init: rtc setup failed: %d\n", ret);
346 #ifdef CONFIG_SERIAL_8250_CONSOLE
347 static int __init da830_evm_console_init(void)
349 return add_preferred_console("ttyS", 2, "115200");
351 console_initcall(da830_evm_console_init);
352 #endif
354 static __init void da830_evm_irq_init(void)
356 struct davinci_soc_info *soc_info = &davinci_soc_info;
358 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA830_N_CP_INTC_IRQ,
359 soc_info->intc_irq_prios);
362 static void __init da830_evm_map_io(void)
364 da830_init();
367 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137 EVM")
368 .phys_io = IO_PHYS,
369 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
370 .boot_params = (DA8XX_DDR_BASE + 0x100),
371 .map_io = da830_evm_map_io,
372 .init_irq = da830_evm_irq_init,
373 .timer = &davinci_timer,
374 .init_machine = da830_evm_init,
375 MACHINE_END