Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-pxa/poodle.c
0004  *
0005  *  Support for the SHARP Poodle Board.
0006  *
0007  * Based on:
0008  *  linux/arch/arm/mach-pxa/lubbock.c Author:   Nicolas Pitre
0009  *
0010  * Change Log
0011  *  12-Dec-2002 Sharp Corporation for Poodle
0012  *  John Lenz <lenz@cs.wisc.edu> updates to 2.6
0013  */
0014 #include <linux/kernel.h>
0015 #include <linux/init.h>
0016 #include <linux/export.h>
0017 #include <linux/platform_device.h>
0018 #include <linux/fb.h>
0019 #include <linux/pm.h>
0020 #include <linux/delay.h>
0021 #include <linux/mtd/physmap.h>
0022 #include <linux/gpio.h>
0023 #include <linux/gpio/machine.h>
0024 #include <linux/i2c.h>
0025 #include <linux/platform_data/i2c-pxa.h>
0026 #include <linux/regulator/machine.h>
0027 #include <linux/spi/spi.h>
0028 #include <linux/spi/ads7846.h>
0029 #include <linux/spi/pxa2xx_spi.h>
0030 #include <linux/mtd/sharpsl.h>
0031 #include <linux/memblock.h>
0032 
0033 #include <asm/mach-types.h>
0034 #include <asm/irq.h>
0035 #include <asm/setup.h>
0036 
0037 #include <asm/mach/arch.h>
0038 #include <asm/mach/map.h>
0039 #include <asm/mach/irq.h>
0040 
0041 #include "pxa25x.h"
0042 #include "udc.h"
0043 #include "poodle.h"
0044 
0045 #include <linux/platform_data/mmc-pxamci.h>
0046 #include <linux/platform_data/irda-pxaficp.h>
0047 #include <linux/platform_data/video-pxafb.h>
0048 #include <linux/platform_data/asoc-poodle.h>
0049 
0050 #include <asm/hardware/scoop.h>
0051 #include <asm/hardware/locomo.h>
0052 #include <asm/mach/sharpsl_param.h>
0053 
0054 #include "generic.h"
0055 #include "devices.h"
0056 
0057 static unsigned long poodle_pin_config[] __initdata = {
0058     /* I/O */
0059     GPIO79_nCS_3,
0060     GPIO80_nCS_4,
0061     GPIO18_RDY,
0062 
0063     /* Clock */
0064     GPIO12_32KHz,
0065 
0066     /* SSP1 */
0067     GPIO23_SSP1_SCLK,
0068     GPIO25_SSP1_TXD,
0069     GPIO26_SSP1_RXD,
0070     GPIO24_GPIO,    /* POODLE_GPIO_TP_CS - SFRM as chip select */
0071 
0072     /* I2S */
0073     GPIO28_I2S_BITCLK_OUT,
0074     GPIO29_I2S_SDATA_IN,
0075     GPIO30_I2S_SDATA_OUT,
0076     GPIO31_I2S_SYNC,
0077     GPIO32_I2S_SYSCLK,
0078 
0079     /* Infra-Red */
0080     GPIO47_FICP_TXD,
0081     GPIO46_FICP_RXD,
0082 
0083     /* FFUART */
0084     GPIO40_FFUART_DTR,
0085     GPIO41_FFUART_RTS,
0086     GPIO39_FFUART_TXD,
0087     GPIO37_FFUART_DSR,
0088     GPIO34_FFUART_RXD,
0089     GPIO35_FFUART_CTS,
0090 
0091     /* LCD */
0092     GPIOxx_LCD_TFT_16BPP,
0093 
0094     /* PC Card */
0095     GPIO48_nPOE,
0096     GPIO49_nPWE,
0097     GPIO50_nPIOR,
0098     GPIO51_nPIOW,
0099     GPIO52_nPCE_1,
0100     GPIO53_nPCE_2,
0101     GPIO54_nPSKTSEL,
0102     GPIO55_nPREG,
0103     GPIO56_nPWAIT,
0104     GPIO57_nIOIS16,
0105 
0106     /* MMC */
0107     GPIO6_MMC_CLK,
0108     GPIO8_MMC_CS0,
0109 
0110     /* GPIO */
0111     GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */
0112     GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */
0113     GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */
0114     GPIO33_GPIO,    /* POODLE_GPIO_SD_PWR1 */
0115 
0116     GPIO20_GPIO,    /* POODLE_GPIO_USB_PULLUP */
0117     GPIO22_GPIO,    /* POODLE_GPIO_IR_ON */
0118 };
0119 
0120 static struct resource poodle_scoop_resources[] = {
0121     [0] = {
0122         .start      = 0x10800000,
0123         .end        = 0x10800fff,
0124         .flags      = IORESOURCE_MEM,
0125     },
0126 };
0127 
0128 static struct scoop_config poodle_scoop_setup = {
0129     .io_dir     = POODLE_SCOOP_IO_DIR,
0130     .io_out     = POODLE_SCOOP_IO_OUT,
0131     .gpio_base  = POODLE_SCOOP_GPIO_BASE,
0132 };
0133 
0134 struct platform_device poodle_scoop_device = {
0135     .name       = "sharp-scoop",
0136     .id     = -1,
0137     .dev        = {
0138         .platform_data  = &poodle_scoop_setup,
0139     },
0140     .num_resources  = ARRAY_SIZE(poodle_scoop_resources),
0141     .resource   = poodle_scoop_resources,
0142 };
0143 
0144 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
0145 {
0146     .dev        = &poodle_scoop_device.dev,
0147     .irq        = POODLE_IRQ_GPIO_CF_IRQ,
0148     .cd_irq     = POODLE_IRQ_GPIO_CF_CD,
0149     .cd_irq_str = "PCMCIA0 CD",
0150 },
0151 };
0152 
0153 static struct scoop_pcmcia_config poodle_pcmcia_config = {
0154     .devs         = &poodle_pcmcia_scoop[0],
0155     .num_devs     = 1,
0156 };
0157 
0158 EXPORT_SYMBOL(poodle_scoop_device);
0159 
0160 /* LoCoMo device */
0161 static struct resource locomo_resources[] = {
0162     [0] = {
0163         .start      = 0x10000000,
0164         .end        = 0x10001fff,
0165         .flags      = IORESOURCE_MEM,
0166     },
0167     [1] = {
0168         .start      = PXA_GPIO_TO_IRQ(10),
0169         .end        = PXA_GPIO_TO_IRQ(10),
0170         .flags      = IORESOURCE_IRQ,
0171     },
0172 };
0173 
0174 static struct locomo_platform_data locomo_info = {
0175     .irq_base   = IRQ_BOARD_START,
0176 };
0177 
0178 static struct platform_device poodle_locomo_device = {
0179     .name       = "locomo",
0180     .id     = 0,
0181     .num_resources  = ARRAY_SIZE(locomo_resources),
0182     .resource   = locomo_resources,
0183     .dev        = {
0184         .platform_data  = &locomo_info,
0185     },
0186 };
0187 
0188 static struct poodle_audio_platform_data poodle_audio_pdata = {
0189     .locomo_dev = &poodle_locomo_device.dev,
0190 
0191     .gpio_amp_on    = POODLE_LOCOMO_GPIO_AMP_ON,
0192     .gpio_mute_l    = POODLE_LOCOMO_GPIO_MUTE_L,
0193     .gpio_mute_r    = POODLE_LOCOMO_GPIO_MUTE_R,
0194     .gpio_232vcc_on = POODLE_LOCOMO_GPIO_232VCC_ON,
0195     .gpio_jk_b      = POODLE_LOCOMO_GPIO_JK_B,
0196 };
0197 
0198 static struct platform_device poodle_audio_device = {
0199     .name   = "poodle-audio",
0200     .id = -1,
0201     .dev.platform_data = &poodle_audio_pdata,
0202 };
0203 
0204 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
0205 static struct pxa2xx_spi_controller poodle_spi_info = {
0206     .num_chipselect = 1,
0207 };
0208 
0209 static struct gpiod_lookup_table poodle_spi_gpio_table = {
0210     .dev_id = "pxa2xx-spi.1",
0211     .table = {
0212         GPIO_LOOKUP_IDX("gpio-pxa", POODLE_GPIO_TP_CS, "cs", 0, GPIO_ACTIVE_LOW),
0213         { },
0214     },
0215 };
0216 
0217 static struct ads7846_platform_data poodle_ads7846_info = {
0218     .model          = 7846,
0219     .vref_delay_usecs   = 100,
0220     .x_plate_ohms       = 419,
0221     .y_plate_ohms       = 486,
0222     .gpio_pendown       = POODLE_GPIO_TP_INT,
0223 };
0224 
0225 static struct spi_board_info poodle_spi_devices[] = {
0226     {
0227         .modalias   = "ads7846",
0228         .max_speed_hz   = 10000,
0229         .bus_num    = 1,
0230         .platform_data  = &poodle_ads7846_info,
0231         .irq        = PXA_GPIO_TO_IRQ(POODLE_GPIO_TP_INT),
0232     },
0233 };
0234 
0235 static void __init poodle_init_spi(void)
0236 {
0237     gpiod_add_lookup_table(&poodle_spi_gpio_table);
0238     pxa2xx_set_spi_info(1, &poodle_spi_info);
0239     spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
0240 }
0241 #else
0242 static inline void poodle_init_spi(void) {}
0243 #endif
0244 
0245 /*
0246  * MMC/SD Device
0247  *
0248  * The card detect interrupt isn't debounced so we delay it by 250ms
0249  * to give the card a chance to fully insert/eject.
0250  */
0251 static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
0252 {
0253     int err;
0254 
0255     err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
0256     if (err)
0257         goto err_free_2;
0258 
0259     err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
0260     if (err)
0261         goto err_free_3;
0262 
0263     gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
0264     gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
0265 
0266     return 0;
0267 
0268 err_free_3:
0269     gpio_free(POODLE_GPIO_SD_PWR);
0270 err_free_2:
0271     return err;
0272 }
0273 
0274 static int poodle_mci_setpower(struct device *dev, unsigned int vdd)
0275 {
0276     struct pxamci_platform_data* p_d = dev->platform_data;
0277 
0278     if ((1 << vdd) & p_d->ocr_mask) {
0279         gpio_set_value(POODLE_GPIO_SD_PWR, 1);
0280         mdelay(2);
0281         gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
0282     } else {
0283         gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
0284         gpio_set_value(POODLE_GPIO_SD_PWR, 0);
0285     }
0286 
0287     return 0;
0288 }
0289 
0290 static void poodle_mci_exit(struct device *dev, void *data)
0291 {
0292     gpio_free(POODLE_GPIO_SD_PWR1);
0293     gpio_free(POODLE_GPIO_SD_PWR);
0294 }
0295 
0296 static struct pxamci_platform_data poodle_mci_platform_data = {
0297     .detect_delay_ms    = 250,
0298     .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
0299     .init           = poodle_mci_init,
0300     .setpower       = poodle_mci_setpower,
0301     .exit           = poodle_mci_exit,
0302 };
0303 
0304 static struct gpiod_lookup_table poodle_mci_gpio_table = {
0305     .dev_id = "pxa2xx-mci.0",
0306     .table = {
0307         GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_DETECT,
0308                 "cd", GPIO_ACTIVE_LOW),
0309         GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_WP,
0310                 "wp", GPIO_ACTIVE_LOW),
0311         { },
0312     },
0313 };
0314 
0315 /*
0316  * Irda
0317  */
0318 static struct pxaficp_platform_data poodle_ficp_platform_data = {
0319     .gpio_pwdown        = POODLE_GPIO_IR_ON,
0320     .transceiver_cap    = IR_SIRMODE | IR_OFF,
0321 };
0322 
0323 
0324 /*
0325  * USB Device Controller
0326  */
0327 static struct pxa2xx_udc_mach_info udc_info __initdata = {
0328     /* no connect GPIO; poodle can't tell connection status */
0329     .gpio_pullup    = POODLE_GPIO_USB_PULLUP,
0330 };
0331 
0332 
0333 /* PXAFB device */
0334 static struct pxafb_mode_info poodle_fb_mode = {
0335     .pixclock   = 144700,
0336     .xres       = 320,
0337     .yres       = 240,
0338     .bpp        = 16,
0339     .hsync_len  = 7,
0340     .left_margin    = 11,
0341     .right_margin   = 30,
0342     .vsync_len  = 2,
0343     .upper_margin   = 2,
0344     .lower_margin   = 0,
0345     .sync       = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
0346 };
0347 
0348 static struct pxafb_mach_info poodle_fb_info = {
0349     .modes      = &poodle_fb_mode,
0350     .num_modes  = 1,
0351     .lcd_conn   = LCD_COLOR_TFT_16BPP,
0352 };
0353 
0354 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
0355 
0356 static struct nand_bbt_descr sharpsl_bbt = {
0357     .options = 0,
0358     .offs = 4,
0359     .len = 2,
0360     .pattern = scan_ff_pattern
0361 };
0362 
0363 static const char * const probes[] = {
0364     "cmdlinepart",
0365     "ofpart",
0366     "sharpslpart",
0367     NULL,
0368 };
0369 
0370 static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
0371     .badblock_pattern   = &sharpsl_bbt,
0372     .part_parsers       = probes,
0373 };
0374 
0375 static struct resource sharpsl_nand_resources[] = {
0376     {
0377         .start  = 0x0C000000,
0378         .end    = 0x0C000FFF,
0379         .flags  = IORESOURCE_MEM,
0380     },
0381 };
0382 
0383 static struct platform_device sharpsl_nand_device = {
0384     .name       = "sharpsl-nand",
0385     .id     = -1,
0386     .resource   = sharpsl_nand_resources,
0387     .num_resources  = ARRAY_SIZE(sharpsl_nand_resources),
0388     .dev.platform_data  = &sharpsl_nand_platform_data,
0389 };
0390 
0391 static struct mtd_partition sharpsl_rom_parts[] = {
0392     {
0393         .name   ="Boot PROM Filesystem",
0394         .offset = 0x00120000,
0395         .size   = MTDPART_SIZ_FULL,
0396     },
0397 };
0398 
0399 static struct physmap_flash_data sharpsl_rom_data = {
0400     .width      = 2,
0401     .nr_parts   = ARRAY_SIZE(sharpsl_rom_parts),
0402     .parts      = sharpsl_rom_parts,
0403 };
0404 
0405 static struct resource sharpsl_rom_resources[] = {
0406     {
0407         .start  = 0x00000000,
0408         .end    = 0x007fffff,
0409         .flags  = IORESOURCE_MEM,
0410     },
0411 };
0412 
0413 static struct platform_device sharpsl_rom_device = {
0414     .name   = "physmap-flash",
0415     .id = -1,
0416     .resource = sharpsl_rom_resources,
0417     .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
0418     .dev.platform_data = &sharpsl_rom_data,
0419 };
0420 
0421 static struct platform_device *devices[] __initdata = {
0422     &poodle_locomo_device,
0423     &poodle_scoop_device,
0424     &poodle_audio_device,
0425     &sharpsl_nand_device,
0426     &sharpsl_rom_device,
0427 };
0428 
0429 static struct i2c_board_info __initdata poodle_i2c_devices[] = {
0430     { I2C_BOARD_INFO("wm8731", 0x1b) },
0431 };
0432 
0433 static void poodle_poweroff(void)
0434 {
0435     pxa_restart(REBOOT_HARD, NULL);
0436 }
0437 
0438 static void __init poodle_init(void)
0439 {
0440     int ret = 0;
0441 
0442     pm_power_off = poodle_poweroff;
0443 
0444     PCFR |= PCFR_OPDE;
0445 
0446     pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
0447 
0448     pxa_set_ffuart_info(NULL);
0449     pxa_set_btuart_info(NULL);
0450     pxa_set_stuart_info(NULL);
0451 
0452     platform_scoop_config = &poodle_pcmcia_config;
0453 
0454     ret = platform_add_devices(devices, ARRAY_SIZE(devices));
0455     if (ret)
0456         pr_warn("poodle: Unable to register LoCoMo device\n");
0457 
0458     pxa_set_fb_info(&poodle_locomo_device.dev, &poodle_fb_info);
0459     pxa_set_udc_info(&udc_info);
0460     gpiod_add_lookup_table(&poodle_mci_gpio_table);
0461     pxa_set_mci_info(&poodle_mci_platform_data);
0462     pxa_set_ficp_info(&poodle_ficp_platform_data);
0463     pxa_set_i2c_info(NULL);
0464     i2c_register_board_info(0, ARRAY_AND_SIZE(poodle_i2c_devices));
0465     poodle_init_spi();
0466     regulator_has_full_constraints();
0467 }
0468 
0469 static void __init fixup_poodle(struct tag *tags, char **cmdline)
0470 {
0471     sharpsl_save_param();
0472     memblock_add(0xa0000000, SZ_32M);
0473 }
0474 
0475 MACHINE_START(POODLE, "SHARP Poodle")
0476     .fixup      = fixup_poodle,
0477     .map_io     = pxa25x_map_io,
0478     .nr_irqs    = POODLE_NR_IRQS,   /* 4 for LoCoMo */
0479     .init_irq   = pxa25x_init_irq,
0480     .handle_irq = pxa25x_handle_irq,
0481     .init_time  = pxa_timer_init,
0482     .init_machine   = poodle_init,
0483     .restart    = pxa_restart,
0484 MACHINE_END