GNU Linux-libre 6.1.90-gnu
[releases.git] / arch / arm / mach-pxa / colibri-evalboard.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  *  linux/arch/arm/mach-pxa/colibri-evalboard.c
4  *
5  *  Support for Toradex Colibri Evaluation Carrier Board
6  *  Daniel Mack <daniel@caiaq.de>
7  *  Marek Vasut <marek.vasut@gmail.com>
8  */
9
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/interrupt.h>
14 #include <linux/gpio/machine.h>
15 #include <asm/mach-types.h>
16 #include <asm/mach/arch.h>
17 #include <linux/i2c.h>
18 #include <linux/platform_data/i2c-pxa.h>
19 #include <asm/io.h>
20
21 #include "pxa27x.h"
22 #include "colibri.h"
23 #include <linux/platform_data/mmc-pxamci.h>
24 #include <linux/platform_data/usb-ohci-pxa27x.h>
25 #include "pxa27x-udc.h"
26
27 #include "generic.h"
28 #include "devices.h"
29
30 /******************************************************************************
31  * SD/MMC card controller
32  ******************************************************************************/
33 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
34 static struct pxamci_platform_data colibri_mci_platform_data = {
35         .ocr_mask               = MMC_VDD_32_33 | MMC_VDD_33_34,
36         .detect_delay_ms        = 200,
37 };
38
39 static struct gpiod_lookup_table colibri_pxa270_mci_gpio_table = {
40         .dev_id = "pxa2xx-mci.0",
41         .table = {
42                 GPIO_LOOKUP("gpio-pxa", GPIO0_COLIBRI_PXA270_SD_DETECT,
43                             "cd", GPIO_ACTIVE_LOW),
44                 { },
45         },
46 };
47
48 static struct gpiod_lookup_table colibri_pxa300_mci_gpio_table = {
49         .dev_id = "pxa2xx-mci.0",
50         .table = {
51                 GPIO_LOOKUP("gpio-pxa", GPIO13_COLIBRI_PXA300_SD_DETECT,
52                             "cd", GPIO_ACTIVE_LOW),
53                 { },
54         },
55 };
56
57 static struct gpiod_lookup_table colibri_pxa320_mci_gpio_table = {
58         .dev_id = "pxa2xx-mci.0",
59         .table = {
60                 GPIO_LOOKUP("gpio-pxa", GPIO28_COLIBRI_PXA320_SD_DETECT,
61                             "cd", GPIO_ACTIVE_LOW),
62                 { },
63         },
64 };
65
66 static void __init colibri_mmc_init(void)
67 {
68         if (machine_is_colibri())       /* PXA270 Colibri */
69                 gpiod_add_lookup_table(&colibri_pxa270_mci_gpio_table);
70         if (machine_is_colibri300())    /* PXA300 Colibri */
71                 gpiod_add_lookup_table(&colibri_pxa300_mci_gpio_table);
72         else                            /* PXA320 Colibri */
73                 gpiod_add_lookup_table(&colibri_pxa320_mci_gpio_table);
74
75         pxa_set_mci_info(&colibri_mci_platform_data);
76 }
77 #else
78 static inline void colibri_mmc_init(void) {}
79 #endif
80
81 /******************************************************************************
82  * USB Host
83  ******************************************************************************/
84 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
85 static int colibri_ohci_init(struct device *dev)
86 {
87         UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
88         return 0;
89 }
90
91 static struct pxaohci_platform_data colibri_ohci_info = {
92         .port_mode      = PMM_PERPORT_MODE,
93         .flags          = ENABLE_PORT1 |
94                           POWER_CONTROL_LOW | POWER_SENSE_LOW,
95         .init           = colibri_ohci_init,
96 };
97
98 static void __init colibri_uhc_init(void)
99 {
100         /* Colibri PXA270 has two usb ports, TBA for 320 */
101         if (machine_is_colibri())
102                 colibri_ohci_info.flags |= ENABLE_PORT2;
103
104         pxa_set_ohci_info(&colibri_ohci_info);
105 }
106 #else
107 static inline void colibri_uhc_init(void) {}
108 #endif
109
110 /******************************************************************************
111  * I2C RTC
112  ******************************************************************************/
113 #if defined(CONFIG_RTC_DRV_DS1307) || defined(CONFIG_RTC_DRV_DS1307_MODULE)
114 static struct i2c_board_info __initdata colibri_i2c_devs[] = {
115         {
116                 I2C_BOARD_INFO("m41t00", 0x68),
117         },
118 };
119
120 static void __init colibri_rtc_init(void)
121 {
122         pxa_set_i2c_info(NULL);
123         i2c_register_board_info(0, ARRAY_AND_SIZE(colibri_i2c_devs));
124 }
125 #else
126 static inline void colibri_rtc_init(void) {}
127 #endif
128
129 void __init colibri_evalboard_init(void)
130 {
131         pxa_set_ffuart_info(NULL);
132         pxa_set_btuart_info(NULL);
133         pxa_set_stuart_info(NULL);
134
135         colibri_mmc_init();
136         colibri_uhc_init();
137         colibri_rtc_init();
138 }