1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Support for Cogent CSB726 4 * 5 * Copyright (c) 2008 Dmitry Eremin-Solenikov 6 */ 7#include <linux/kernel.h> 8#include <linux/init.h> 9#include <linux/io.h> 10#include <linux/gpio/machine.h> 11#include <linux/platform_device.h> 12#include <linux/mtd/physmap.h> 13#include <linux/mtd/partitions.h> 14#include <linux/sm501.h> 15#include <linux/smsc911x.h> 16#include <linux/platform_data/i2c-pxa.h> 17 18#include <asm/mach-types.h> 19#include <asm/mach/arch.h> 20#include "csb726.h" 21#include "pxa27x.h" 22#include <linux/platform_data/mmc-pxamci.h> 23#include <linux/platform_data/usb-ohci-pxa27x.h> 24#include <mach/audio.h> 25#include <mach/smemc.h> 26 27#include "generic.h" 28#include "devices.h" 29 30/* 31 * n/a: 2, 5, 6, 7, 8, 23, 24, 25, 26, 27, 87, 88, 89, 32 * nu: 58 -- 77, 90, 91, 93, 102, 105-108, 114-116, 33 * XXX: 21, 34 * XXX: 79 CS_3 for LAN9215 or PSKTSEL on R2, R3 35 * XXX: 33 CS_5 for LAN9215 on R1 36 */ 37 38static unsigned long csb726_pin_config[] = { 39 GPIO78_nCS_2, /* EXP_CS */ 40 GPIO79_nCS_3, /* SMSC9215 */ 41 GPIO80_nCS_4, /* SM501 */ 42 43 GPIO52_GPIO, /* #SMSC9251 int */ 44 GPIO53_GPIO, /* SM501 int */ 45 46 GPIO1_GPIO, /* GPIO0 */ 47 GPIO11_GPIO, /* GPIO1 */ 48 GPIO9_GPIO, /* GPIO2 */ 49 GPIO10_GPIO, /* GPIO3 */ 50 GPIO16_PWM0_OUT, /* or GPIO4 */ 51 GPIO17_PWM1_OUT, /* or GPIO5 */ 52 GPIO94_GPIO, /* GPIO6 */ 53 GPIO95_GPIO, /* GPIO7 */ 54 GPIO96_GPIO, /* GPIO8 */ 55 GPIO97_GPIO, /* GPIO9 */ 56 GPIO15_GPIO, /* EXP_IRQ */ 57 GPIO18_RDY, /* EXP_WAIT */ 58 59 GPIO0_GPIO, /* PWR_INT */ 60 GPIO104_GPIO, /* PWR_OFF */ 61 62 GPIO12_GPIO, /* touch irq */ 63 64 GPIO13_SSP2_TXD, 65 GPIO14_SSP2_SFRM, 66 MFP_CFG_OUT(GPIO19, AF1, DRIVE_LOW),/* SSP2_SYSCLK */ 67 GPIO22_SSP2_SCLK, 68 69 GPIO81_SSP3_TXD, 70 GPIO82_SSP3_RXD, 71 GPIO83_SSP3_SFRM, 72 GPIO84_SSP3_SCLK, 73 74 GPIO20_GPIO, /* SDIO int */ 75 GPIO32_MMC_CLK, 76 GPIO92_MMC_DAT_0, 77 GPIO109_MMC_DAT_1, 78 GPIO110_MMC_DAT_2, 79 GPIO111_MMC_DAT_3, 80 GPIO112_MMC_CMD, 81 GPIO100_GPIO, /* SD CD */ 82 GPIO101_GPIO, /* SD WP */ 83 84 GPIO28_AC97_BITCLK, 85 GPIO29_AC97_SDATA_IN_0, 86 GPIO30_AC97_SDATA_OUT, 87 GPIO31_AC97_SYNC, 88 GPIO113_AC97_nRESET, 89 90 GPIO34_FFUART_RXD, 91 GPIO35_FFUART_CTS, 92 GPIO36_FFUART_DCD, 93 GPIO37_FFUART_DSR, 94 GPIO38_FFUART_RI, 95 GPIO39_FFUART_TXD, 96 GPIO40_FFUART_DTR, 97 GPIO41_FFUART_RTS, 98 99 GPIO42_BTUART_RXD, 100 GPIO43_BTUART_TXD, 101 GPIO44_BTUART_CTS, 102 GPIO45_BTUART_RTS, 103 104 GPIO46_STUART_RXD, 105 GPIO47_STUART_TXD, 106 107 GPIO48_nPOE, 108 GPIO49_nPWE, 109 GPIO50_nPIOR, 110 GPIO51_nPIOW, 111 GPIO54_nPCE_2, 112 GPIO55_nPREG, 113 GPIO56_nPWAIT, 114 GPIO57_nIOIS16, /* maybe unused */ 115 GPIO85_nPCE_1, 116 GPIO98_GPIO, /* CF IRQ */ 117 GPIO99_GPIO, /* CF CD */ 118 GPIO103_GPIO, /* Reset */ 119 120 GPIO117_I2C_SCL, 121 GPIO118_I2C_SDA, 122}; 123 124static struct pxamci_platform_data csb726_mci = { 125 .detect_delay_ms = 500, 126 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 127 /* FIXME setpower */ 128}; 129 130static struct gpiod_lookup_table csb726_mci_gpio_table = { 131 .dev_id = "pxa2xx-mci.0", 132 .table = { 133 /* Card detect on GPIO 100 */ 134 GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_DETECT, 135 "cd", GPIO_ACTIVE_LOW), 136 /* Write protect on GPIO 101 */ 137 GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_RO, 138 "wp", GPIO_ACTIVE_LOW), 139 { }, 140 }, 141}; 142 143static struct pxaohci_platform_data csb726_ohci_platform_data = { 144 .port_mode = PMM_NPS_MODE, 145 .flags = ENABLE_PORT1 | NO_OC_PROTECTION, 146}; 147 148static struct mtd_partition csb726_flash_partitions[] = { 149 { 150 .name = "Bootloader", 151 .offset = 0, 152 .size = CSB726_FLASH_uMON, 153 .mask_flags = MTD_WRITEABLE /* force read-only */ 154 }, 155 { 156 .name = "root", 157 .offset = MTDPART_OFS_APPEND, 158 .size = MTDPART_SIZ_FULL, 159 } 160}; 161 162static struct physmap_flash_data csb726_flash_data = { 163 .width = 2, 164 .parts = csb726_flash_partitions, 165 .nr_parts = ARRAY_SIZE(csb726_flash_partitions), 166}; 167 168static struct resource csb726_flash_resources[] = { 169 { 170 .start = PXA_CS0_PHYS, 171 .end = PXA_CS0_PHYS + CSB726_FLASH_SIZE - 1 , 172 .flags = IORESOURCE_MEM, 173 } 174}; 175 176static struct platform_device csb726_flash = { 177 .name = "physmap-flash", 178 .dev = { 179 .platform_data = &csb726_flash_data, 180 }, 181 .resource = csb726_flash_resources, 182 .num_resources = ARRAY_SIZE(csb726_flash_resources), 183}; 184 185static struct resource csb726_sm501_resources[] = { 186 { 187 .start = PXA_CS4_PHYS, 188 .end = PXA_CS4_PHYS + SZ_8M - 1, 189 .flags = IORESOURCE_MEM, 190 .name = "sm501-localmem", 191 }, 192 { 193 .start = PXA_CS4_PHYS + SZ_64M - SZ_2M, 194 .end = PXA_CS4_PHYS + SZ_64M - 1, 195 .flags = IORESOURCE_MEM, 196 .name = "sm501-regs", 197 }, 198 { 199 .start = CSB726_IRQ_SM501, 200 .end = CSB726_IRQ_SM501, 201 .flags = IORESOURCE_IRQ, 202 }, 203}; 204 205static struct sm501_initdata csb726_sm501_initdata = { 206/* .devices = SM501_USE_USB_HOST, */ 207 .devices = SM501_USE_USB_HOST | SM501_USE_UART0 | SM501_USE_UART1, 208}; 209 210static struct sm501_platdata csb726_sm501_platdata = { 211 .init = &csb726_sm501_initdata, 212}; 213 214static struct platform_device csb726_sm501 = { 215 .name = "sm501", 216 .id = 0, 217 .num_resources = ARRAY_SIZE(csb726_sm501_resources), 218 .resource = csb726_sm501_resources, 219 .dev = { 220 .platform_data = &csb726_sm501_platdata, 221 }, 222}; 223 224static struct resource csb726_lan_resources[] = { 225 { 226 .start = PXA_CS3_PHYS, 227 .end = PXA_CS3_PHYS + SZ_64K - 1, 228 .flags = IORESOURCE_MEM, 229 }, 230 { 231 .start = CSB726_IRQ_LAN, 232 .end = CSB726_IRQ_LAN, 233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, 234 }, 235}; 236 237struct smsc911x_platform_config csb726_lan_config = { 238 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, 239 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, 240 .flags = SMSC911X_USE_32BIT, 241 .phy_interface = PHY_INTERFACE_MODE_MII, 242}; 243 244 245static struct platform_device csb726_lan = { 246 .name = "smsc911x", 247 .id = -1, 248 .num_resources = ARRAY_SIZE(csb726_lan_resources), 249 .resource = csb726_lan_resources, 250 .dev = { 251 .platform_data = &csb726_lan_config, 252 }, 253}; 254 255static struct platform_device *devices[] __initdata = { 256 &csb726_flash, 257 &csb726_sm501, 258 &csb726_lan, 259}; 260 261static void __init csb726_init(void) 262{ 263 pxa2xx_mfp_config(ARRAY_AND_SIZE(csb726_pin_config)); 264/* __raw_writel(0x7ffc3ffc, MSC1); *//* LAN9215/EXP_CS */ 265/* __raw_writel(0x06697ff4, MSC2); *//* none/SM501 */ 266 __raw_writel((__raw_readl(MSC2) & ~0xffff) | 0x7ff4, MSC2); /* SM501 */ 267 268 pxa_set_ffuart_info(NULL); 269 pxa_set_btuart_info(NULL); 270 pxa_set_stuart_info(NULL); 271 pxa_set_i2c_info(NULL); 272 pxa27x_set_i2c_power_info(NULL); 273 gpiod_add_lookup_table(&csb726_mci_gpio_table); 274 pxa_set_mci_info(&csb726_mci); 275 pxa_set_ohci_info(&csb726_ohci_platform_data); 276 pxa_set_ac97_info(NULL); 277 278 platform_add_devices(devices, ARRAY_SIZE(devices)); 279} 280 281MACHINE_START(CSB726, "Cogent CSB726") 282 .atag_offset = 0x100, 283 .map_io = pxa27x_map_io, 284 .nr_irqs = PXA_NR_IRQS, 285 .init_irq = pxa27x_init_irq, 286 .handle_irq = pxa27x_handle_irq, 287 .init_machine = csb726_init, 288 .init_time = pxa_timer_init, 289 .restart = pxa_restart, 290MACHINE_END 291