Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  Support for Cogent CSB726
0004  *
0005  *  Copyright (c) 2008 Dmitry Eremin-Solenikov
0006  */
0007 #include <linux/kernel.h>
0008 #include <linux/init.h>
0009 #include <linux/io.h>
0010 #include <linux/gpio/machine.h>
0011 #include <linux/platform_device.h>
0012 #include <linux/mtd/physmap.h>
0013 #include <linux/mtd/partitions.h>
0014 #include <linux/sm501.h>
0015 #include <linux/smsc911x.h>
0016 #include <linux/platform_data/i2c-pxa.h>
0017 
0018 #include <asm/mach-types.h>
0019 #include <asm/mach/arch.h>
0020 
0021 #include "csb726.h"
0022 #include "pxa27x.h"
0023 #include <linux/platform_data/mmc-pxamci.h>
0024 #include <linux/platform_data/usb-ohci-pxa27x.h>
0025 #include <linux/platform_data/asoc-pxa.h>
0026 #include "smemc.h"
0027 
0028 #include "generic.h"
0029 #include "devices.h"
0030 
0031 /*
0032  * n/a: 2, 5, 6, 7, 8, 23, 24, 25, 26, 27, 87, 88, 89,
0033  * nu: 58 -- 77, 90, 91, 93, 102, 105-108, 114-116,
0034  * XXX: 21,
0035  * XXX: 79 CS_3 for LAN9215 or PSKTSEL on R2, R3
0036  * XXX: 33 CS_5 for LAN9215 on R1
0037  */
0038 
0039 static unsigned long csb726_pin_config[] = {
0040     GPIO78_nCS_2, /* EXP_CS */
0041     GPIO79_nCS_3, /* SMSC9215 */
0042     GPIO80_nCS_4, /* SM501 */
0043 
0044     GPIO52_GPIO, /* #SMSC9251 int */
0045     GPIO53_GPIO, /* SM501 int */
0046 
0047     GPIO1_GPIO, /* GPIO0 */
0048     GPIO11_GPIO, /* GPIO1 */
0049     GPIO9_GPIO, /* GPIO2 */
0050     GPIO10_GPIO, /* GPIO3 */
0051     GPIO16_PWM0_OUT, /* or GPIO4 */
0052     GPIO17_PWM1_OUT, /* or GPIO5 */
0053     GPIO94_GPIO, /* GPIO6 */
0054     GPIO95_GPIO, /* GPIO7 */
0055     GPIO96_GPIO, /* GPIO8 */
0056     GPIO97_GPIO, /* GPIO9 */
0057     GPIO15_GPIO, /* EXP_IRQ */
0058     GPIO18_RDY, /* EXP_WAIT */
0059 
0060     GPIO0_GPIO, /* PWR_INT */
0061     GPIO104_GPIO, /* PWR_OFF */
0062 
0063     GPIO12_GPIO, /* touch irq */
0064 
0065     GPIO13_SSP2_TXD,
0066     GPIO14_SSP2_SFRM,
0067     MFP_CFG_OUT(GPIO19, AF1, DRIVE_LOW),/* SSP2_SYSCLK */
0068     GPIO22_SSP2_SCLK,
0069 
0070     GPIO81_SSP3_TXD,
0071     GPIO82_SSP3_RXD,
0072     GPIO83_SSP3_SFRM,
0073     GPIO84_SSP3_SCLK,
0074 
0075     GPIO20_GPIO, /* SDIO int */
0076     GPIO32_MMC_CLK,
0077     GPIO92_MMC_DAT_0,
0078     GPIO109_MMC_DAT_1,
0079     GPIO110_MMC_DAT_2,
0080     GPIO111_MMC_DAT_3,
0081     GPIO112_MMC_CMD,
0082     GPIO100_GPIO, /* SD CD */
0083     GPIO101_GPIO, /* SD WP */
0084 
0085     GPIO28_AC97_BITCLK,
0086     GPIO29_AC97_SDATA_IN_0,
0087     GPIO30_AC97_SDATA_OUT,
0088     GPIO31_AC97_SYNC,
0089     GPIO113_AC97_nRESET,
0090 
0091     GPIO34_FFUART_RXD,
0092     GPIO35_FFUART_CTS,
0093     GPIO36_FFUART_DCD,
0094     GPIO37_FFUART_DSR,
0095     GPIO38_FFUART_RI,
0096     GPIO39_FFUART_TXD,
0097     GPIO40_FFUART_DTR,
0098     GPIO41_FFUART_RTS,
0099 
0100     GPIO42_BTUART_RXD,
0101     GPIO43_BTUART_TXD,
0102     GPIO44_BTUART_CTS,
0103     GPIO45_BTUART_RTS,
0104 
0105     GPIO46_STUART_RXD,
0106     GPIO47_STUART_TXD,
0107 
0108     GPIO48_nPOE,
0109     GPIO49_nPWE,
0110     GPIO50_nPIOR,
0111     GPIO51_nPIOW,
0112     GPIO54_nPCE_2,
0113     GPIO55_nPREG,
0114     GPIO56_nPWAIT,
0115     GPIO57_nIOIS16, /* maybe unused */
0116     GPIO85_nPCE_1,
0117     GPIO98_GPIO, /* CF IRQ */
0118     GPIO99_GPIO, /* CF CD */
0119     GPIO103_GPIO, /* Reset */
0120 
0121     GPIO117_I2C_SCL,
0122     GPIO118_I2C_SDA,
0123 };
0124 
0125 static struct pxamci_platform_data csb726_mci = {
0126     .detect_delay_ms    = 500,
0127     .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
0128     /* FIXME setpower */
0129 };
0130 
0131 static struct gpiod_lookup_table csb726_mci_gpio_table = {
0132     .dev_id = "pxa2xx-mci.0",
0133     .table = {
0134         /* Card detect on GPIO 100 */
0135         GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_DETECT,
0136                 "cd", GPIO_ACTIVE_LOW),
0137         /* Write protect on GPIO 101 */
0138         GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_RO,
0139                 "wp", GPIO_ACTIVE_LOW),
0140         { },
0141     },
0142 };
0143 
0144 static struct pxaohci_platform_data csb726_ohci_platform_data = {
0145     .port_mode  = PMM_NPS_MODE,
0146     .flags      = ENABLE_PORT1 | NO_OC_PROTECTION,
0147 };
0148 
0149 static struct mtd_partition csb726_flash_partitions[] = {
0150     {
0151         .name       = "Bootloader",
0152         .offset     = 0,
0153         .size       = CSB726_FLASH_uMON,
0154         .mask_flags = MTD_WRITEABLE  /* force read-only */
0155     },
0156     {
0157         .name       = "root",
0158         .offset     = MTDPART_OFS_APPEND,
0159         .size       = MTDPART_SIZ_FULL,
0160     }
0161 };
0162 
0163 static struct physmap_flash_data csb726_flash_data = {
0164     .width      = 2,
0165     .parts      = csb726_flash_partitions,
0166     .nr_parts   = ARRAY_SIZE(csb726_flash_partitions),
0167 };
0168 
0169 static struct resource csb726_flash_resources[] = {
0170     {
0171         .start          = PXA_CS0_PHYS,
0172         .end            = PXA_CS0_PHYS + CSB726_FLASH_SIZE - 1 ,
0173         .flags          = IORESOURCE_MEM,
0174     }
0175 };
0176 
0177 static struct platform_device csb726_flash = {
0178     .name           = "physmap-flash",
0179     .dev            = {
0180         .platform_data  = &csb726_flash_data,
0181     },
0182     .resource       = csb726_flash_resources,
0183     .num_resources  = ARRAY_SIZE(csb726_flash_resources),
0184 };
0185 
0186 static struct resource csb726_sm501_resources[] = {
0187     {
0188         .start          = PXA_CS4_PHYS,
0189         .end            = PXA_CS4_PHYS + SZ_8M - 1,
0190         .flags          = IORESOURCE_MEM,
0191         .name       = "sm501-localmem",
0192     },
0193     {
0194         .start          = PXA_CS4_PHYS + SZ_64M - SZ_2M,
0195         .end            = PXA_CS4_PHYS + SZ_64M - 1,
0196         .flags          = IORESOURCE_MEM,
0197         .name       = "sm501-regs",
0198     },
0199     {
0200         .start      = CSB726_IRQ_SM501,
0201         .end        = CSB726_IRQ_SM501,
0202         .flags      = IORESOURCE_IRQ,
0203     },
0204 };
0205 
0206 static struct sm501_initdata csb726_sm501_initdata = {
0207 /*  .devices    = SM501_USE_USB_HOST, */
0208     .devices    = SM501_USE_USB_HOST | SM501_USE_UART0 | SM501_USE_UART1,
0209 };
0210 
0211 static struct sm501_platdata csb726_sm501_platdata = {
0212     .init       = &csb726_sm501_initdata,
0213 };
0214 
0215 static struct platform_device csb726_sm501 = {
0216     .name       = "sm501",
0217     .id     = 0,
0218     .num_resources  = ARRAY_SIZE(csb726_sm501_resources),
0219     .resource   = csb726_sm501_resources,
0220     .dev        = {
0221         .platform_data = &csb726_sm501_platdata,
0222     },
0223 };
0224 
0225 static struct resource csb726_lan_resources[] = {
0226     {
0227         .start  = PXA_CS3_PHYS,
0228         .end    = PXA_CS3_PHYS + SZ_64K - 1,
0229         .flags  = IORESOURCE_MEM,
0230     },
0231     {
0232         .start  = CSB726_IRQ_LAN,
0233         .end    = CSB726_IRQ_LAN,
0234         .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
0235     },
0236 };
0237 
0238 struct smsc911x_platform_config csb726_lan_config = {
0239     .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
0240     .irq_type   = SMSC911X_IRQ_TYPE_PUSH_PULL,
0241     .flags      = SMSC911X_USE_32BIT,
0242     .phy_interface  = PHY_INTERFACE_MODE_MII,
0243 };
0244 
0245 
0246 static struct platform_device csb726_lan = {
0247     .name       = "smsc911x",
0248     .id     = -1,
0249     .num_resources  = ARRAY_SIZE(csb726_lan_resources),
0250     .resource   = csb726_lan_resources,
0251     .dev        = {
0252         .platform_data  = &csb726_lan_config,
0253     },
0254 };
0255 
0256 static struct platform_device *devices[] __initdata = {
0257     &csb726_flash,
0258     &csb726_sm501,
0259     &csb726_lan,
0260 };
0261 
0262 static void __init csb726_init(void)
0263 {
0264     pxa2xx_mfp_config(ARRAY_AND_SIZE(csb726_pin_config));
0265 /*  __raw_writel(0x7ffc3ffc, MSC1); *//* LAN9215/EXP_CS */
0266 /*  __raw_writel(0x06697ff4, MSC2); *//* none/SM501 */
0267     __raw_writel((__raw_readl(MSC2) & ~0xffff) | 0x7ff4, MSC2); /* SM501 */
0268 
0269     pxa_set_ffuart_info(NULL);
0270     pxa_set_btuart_info(NULL);
0271     pxa_set_stuart_info(NULL);
0272     pxa_set_i2c_info(NULL);
0273     pxa27x_set_i2c_power_info(NULL);
0274     gpiod_add_lookup_table(&csb726_mci_gpio_table);
0275     pxa_set_mci_info(&csb726_mci);
0276     pxa_set_ohci_info(&csb726_ohci_platform_data);
0277     pxa_set_ac97_info(NULL);
0278 
0279     platform_add_devices(devices, ARRAY_SIZE(devices));
0280 }
0281 
0282 MACHINE_START(CSB726, "Cogent CSB726")
0283     .atag_offset    = 0x100,
0284     .map_io         = pxa27x_map_io,
0285     .nr_irqs    = PXA_NR_IRQS,
0286     .init_irq       = pxa27x_init_irq,
0287     .handle_irq       = pxa27x_handle_irq,
0288     .init_machine   = csb726_init,
0289     .init_time  = pxa_timer_init,
0290     .restart    = pxa_restart,
0291 MACHINE_END