root/arch/arm/mach-pxa/cm-x270.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. cmx270_init_rtc
  2. cmx270_init_rtc
  3. cmx270_marathon_probe
  4. cmx270_marathon_remove
  5. cmx270_init_2700G
  6. cmx270_init_2700G
  7. cmx270_init_ohci
  8. cmx270_init_ohci
  9. cmx270_init_mmc
  10. cmx270_init_mmc
  11. cm_x270_libertas_setup
  12. cm_x270_libertas_teardown
  13. cmx270_init_spi
  14. cmx270_init_spi
  15. cmx270_init

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * linux/arch/arm/mach-pxa/cm-x270.c
   4  *
   5  * Copyright (C) 2007, 2008 CompuLab, Ltd.
   6  * Mike Rapoport <mike@compulab.co.il>
   7  */
   8 
   9 #include <linux/platform_device.h>
  10 #include <linux/irq.h>
  11 #include <linux/gpio.h>
  12 #include <linux/gpio/machine.h>
  13 #include <linux/delay.h>
  14 
  15 #include <linux/platform_data/rtc-v3020.h>
  16 #include <video/mbxfb.h>
  17 
  18 #include <linux/spi/spi.h>
  19 #include <linux/spi/pxa2xx_spi.h>
  20 #include <linux/spi/libertas_spi.h>
  21 
  22 #include "pxa27x.h"
  23 #include <linux/platform_data/usb-ohci-pxa27x.h>
  24 #include <linux/platform_data/mmc-pxamci.h>
  25 
  26 #include "generic.h"
  27 
  28 /* physical address if local-bus attached devices */
  29 #define RTC_PHYS_BASE           (PXA_CS1_PHYS + (5 << 22))
  30 
  31 /* GPIO IRQ usage */
  32 #define GPIO83_MMC_IRQ          (83)
  33 
  34 #define CMX270_MMC_IRQ          PXA_GPIO_TO_IRQ(GPIO83_MMC_IRQ)
  35 
  36 /* MMC power enable */
  37 #define GPIO105_MMC_POWER       (105)
  38 
  39 /* WLAN GPIOS */
  40 #define GPIO19_WLAN_STRAP       (19)
  41 #define GPIO102_WLAN_RST        (102)
  42 
  43 static unsigned long cmx270_pin_config[] = {
  44         /* AC'97 */
  45         GPIO28_AC97_BITCLK,
  46         GPIO29_AC97_SDATA_IN_0,
  47         GPIO30_AC97_SDATA_OUT,
  48         GPIO31_AC97_SYNC,
  49         GPIO98_AC97_SYSCLK,
  50         GPIO113_AC97_nRESET,
  51 
  52         /* BTUART */
  53         GPIO42_BTUART_RXD,
  54         GPIO43_BTUART_TXD,
  55         GPIO44_BTUART_CTS,
  56         GPIO45_BTUART_RTS,
  57 
  58         /* STUART */
  59         GPIO46_STUART_RXD,
  60         GPIO47_STUART_TXD,
  61 
  62         /* MCI controller */
  63         GPIO32_MMC_CLK,
  64         GPIO112_MMC_CMD,
  65         GPIO92_MMC_DAT_0,
  66         GPIO109_MMC_DAT_1,
  67         GPIO110_MMC_DAT_2,
  68         GPIO111_MMC_DAT_3,
  69 
  70         /* LCD */
  71         GPIOxx_LCD_TFT_16BPP,
  72 
  73         /* I2C */
  74         GPIO117_I2C_SCL,
  75         GPIO118_I2C_SDA,
  76 
  77         /* SSP1 */
  78         GPIO23_SSP1_SCLK,
  79         GPIO24_SSP1_SFRM,
  80         GPIO25_SSP1_TXD,
  81         GPIO26_SSP1_RXD,
  82 
  83         /* SSP2 */
  84         GPIO19_GPIO,    /* SSP2 clock is used as GPIO for Libertas pin-strap */
  85         GPIO14_GPIO,
  86         GPIO87_SSP2_TXD,
  87         GPIO88_SSP2_RXD,
  88 
  89         /* PC Card */
  90         GPIO48_nPOE,
  91         GPIO49_nPWE,
  92         GPIO50_nPIOR,
  93         GPIO51_nPIOW,
  94         GPIO85_nPCE_1,
  95         GPIO54_nPCE_2,
  96         GPIO55_nPREG,
  97         GPIO56_nPWAIT,
  98         GPIO57_nIOIS16,
  99 
 100         /* SDRAM and local bus */
 101         GPIO15_nCS_1,
 102         GPIO78_nCS_2,
 103         GPIO79_nCS_3,
 104         GPIO80_nCS_4,
 105         GPIO33_nCS_5,
 106         GPIO49_nPWE,
 107         GPIO18_RDY,
 108 
 109         /* GPIO */
 110         GPIO0_GPIO      | WAKEUP_ON_EDGE_BOTH,
 111         GPIO105_GPIO    | MFP_LPM_DRIVE_HIGH,   /* MMC/SD power */
 112         GPIO53_GPIO,                            /* PC card reset */
 113         GPIO102_GPIO,                           /* WLAN reset */
 114 
 115         /* NAND controls */
 116         GPIO11_GPIO     | MFP_LPM_DRIVE_HIGH,   /* NAND CE# */
 117         GPIO89_GPIO,                            /* NAND Ready/Busy */
 118 
 119         /* interrupts */
 120         GPIO10_GPIO,    /* DM9000 interrupt */
 121         GPIO83_GPIO,    /* MMC card detect */
 122         GPIO95_GPIO,    /* WLAN interrupt */
 123 };
 124 
 125 /* V3020 RTC */
 126 #if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
 127 static struct resource cmx270_v3020_resource[] = {
 128         [0] = {
 129                 .start = RTC_PHYS_BASE,
 130                 .end   = RTC_PHYS_BASE + 4,
 131                 .flags = IORESOURCE_MEM,
 132         },
 133 };
 134 
 135 struct v3020_platform_data cmx270_v3020_pdata = {
 136         .leftshift = 16,
 137 };
 138 
 139 static struct platform_device cmx270_rtc_device = {
 140         .name           = "v3020",
 141         .num_resources  = ARRAY_SIZE(cmx270_v3020_resource),
 142         .resource       = cmx270_v3020_resource,
 143         .id             = -1,
 144         .dev            = {
 145                 .platform_data = &cmx270_v3020_pdata,
 146         }
 147 };
 148 
 149 static void __init cmx270_init_rtc(void)
 150 {
 151         platform_device_register(&cmx270_rtc_device);
 152 }
 153 #else
 154 static inline void cmx270_init_rtc(void) {}
 155 #endif
 156 
 157 /* 2700G graphics */
 158 #if defined(CONFIG_FB_MBX) || defined(CONFIG_FB_MBX_MODULE)
 159 static u64 fb_dma_mask = ~(u64)0;
 160 
 161 static struct resource cmx270_2700G_resource[] = {
 162         /* frame buffer memory including ODFB and External SDRAM */
 163         [0] = {
 164                 .start = PXA_CS2_PHYS,
 165                 .end   = PXA_CS2_PHYS + 0x01ffffff,
 166                 .flags = IORESOURCE_MEM,
 167         },
 168         /* Marathon registers */
 169         [1] = {
 170                 .start = PXA_CS2_PHYS + 0x03fe0000,
 171                 .end   = PXA_CS2_PHYS + 0x03ffffff,
 172                 .flags = IORESOURCE_MEM,
 173         },
 174 };
 175 
 176 static unsigned long cmx270_marathon_on[] = {
 177         GPIO58_GPIO,
 178         GPIO59_GPIO,
 179         GPIO60_GPIO,
 180         GPIO61_GPIO,
 181         GPIO62_GPIO,
 182         GPIO63_GPIO,
 183         GPIO64_GPIO,
 184         GPIO65_GPIO,
 185         GPIO66_GPIO,
 186         GPIO67_GPIO,
 187         GPIO68_GPIO,
 188         GPIO69_GPIO,
 189         GPIO70_GPIO,
 190         GPIO71_GPIO,
 191         GPIO72_GPIO,
 192         GPIO73_GPIO,
 193         GPIO74_GPIO,
 194         GPIO75_GPIO,
 195         GPIO76_GPIO,
 196         GPIO77_GPIO,
 197 };
 198 
 199 static unsigned long cmx270_marathon_off[] = {
 200         GPIOxx_LCD_TFT_16BPP,
 201 };
 202 
 203 static int cmx270_marathon_probe(struct fb_info *fb)
 204 {
 205         int gpio, err;
 206 
 207         for (gpio = 58; gpio <= 77; gpio++) {
 208                 err = gpio_request(gpio, "LCD");
 209                 if (err)
 210                         return err;
 211                 gpio_direction_input(gpio);
 212         }
 213 
 214         pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_on));
 215         return 0;
 216 }
 217 
 218 static int cmx270_marathon_remove(struct fb_info *fb)
 219 {
 220         int gpio;
 221 
 222         pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_off));
 223 
 224         for (gpio = 58; gpio <= 77; gpio++)
 225                 gpio_free(gpio);
 226 
 227         return 0;
 228 }
 229 
 230 static struct mbxfb_platform_data cmx270_2700G_data = {
 231         .xres = {
 232                 .min = 240,
 233                 .max = 1200,
 234                 .defval = 640,
 235         },
 236         .yres = {
 237                 .min = 240,
 238                 .max = 1200,
 239                 .defval = 480,
 240         },
 241         .bpp = {
 242                 .min = 16,
 243                 .max = 32,
 244                 .defval = 16,
 245         },
 246         .memsize = 8*1024*1024,
 247         .probe = cmx270_marathon_probe,
 248         .remove = cmx270_marathon_remove,
 249 };
 250 
 251 static struct platform_device cmx270_2700G = {
 252         .name           = "mbx-fb",
 253         .dev            = {
 254                 .platform_data  = &cmx270_2700G_data,
 255                 .dma_mask       = &fb_dma_mask,
 256                 .coherent_dma_mask = 0xffffffff,
 257         },
 258         .num_resources  = ARRAY_SIZE(cmx270_2700G_resource),
 259         .resource       = cmx270_2700G_resource,
 260         .id             = -1,
 261 };
 262 
 263 static void __init cmx270_init_2700G(void)
 264 {
 265         platform_device_register(&cmx270_2700G);
 266 }
 267 #else
 268 static inline void cmx270_init_2700G(void) {}
 269 #endif
 270 
 271 /* PXA27x OHCI controller setup */
 272 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 273 static struct pxaohci_platform_data cmx270_ohci_platform_data = {
 274         .port_mode      = PMM_PERPORT_MODE,
 275         .flags          = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
 276 };
 277 
 278 static void __init cmx270_init_ohci(void)
 279 {
 280         pxa_set_ohci_info(&cmx270_ohci_platform_data);
 281 }
 282 #else
 283 static inline void cmx270_init_ohci(void) {}
 284 #endif
 285 
 286 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
 287 static struct pxamci_platform_data cmx270_mci_platform_data = {
 288         .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
 289 };
 290 
 291 static struct gpiod_lookup_table cmx270_mci_gpio_table = {
 292         .dev_id = "pxa2xx-mci.0",
 293         .table = {
 294                 /* Card detect on GPIO 83 */
 295                 GPIO_LOOKUP("gpio-pxa", GPIO83_MMC_IRQ, "cd", GPIO_ACTIVE_LOW),
 296                 /* Power on GPIO 105 */
 297                 GPIO_LOOKUP("gpio-pxa", GPIO105_MMC_POWER,
 298                             "power", GPIO_ACTIVE_LOW),
 299                 { },
 300         },
 301 };
 302 
 303 static void __init cmx270_init_mmc(void)
 304 {
 305         gpiod_add_lookup_table(&cmx270_mci_gpio_table);
 306         pxa_set_mci_info(&cmx270_mci_platform_data);
 307 }
 308 #else
 309 static inline void cmx270_init_mmc(void) {}
 310 #endif
 311 
 312 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
 313 static struct pxa2xx_spi_controller cm_x270_spi_info = {
 314         .num_chipselect = 1,
 315         .enable_dma     = 1,
 316 };
 317 
 318 static struct pxa2xx_spi_chip cm_x270_libertas_chip = {
 319         .rx_threshold   = 1,
 320         .tx_threshold   = 1,
 321         .timeout        = 1000,
 322         .gpio_cs        = 14,
 323 };
 324 
 325 static unsigned long cm_x270_libertas_pin_config[] = {
 326         /* SSP2 */
 327         GPIO19_SSP2_SCLK,
 328         GPIO14_GPIO,
 329         GPIO87_SSP2_TXD,
 330         GPIO88_SSP2_RXD,
 331 
 332 };
 333 
 334 static int cm_x270_libertas_setup(struct spi_device *spi)
 335 {
 336         int err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
 337         if (err)
 338                 return err;
 339 
 340         err = gpio_request(GPIO102_WLAN_RST, "WLAN RST");
 341         if (err)
 342                 goto err_free_strap;
 343 
 344         err = gpio_direction_output(GPIO102_WLAN_RST, 0);
 345         if (err)
 346                 goto err_free_strap;
 347         msleep(100);
 348 
 349         err = gpio_direction_output(GPIO19_WLAN_STRAP, 1);
 350         if (err)
 351                 goto err_free_strap;
 352         msleep(100);
 353 
 354         pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config));
 355 
 356         gpio_set_value(GPIO102_WLAN_RST, 1);
 357         msleep(100);
 358 
 359         spi->bits_per_word = 16;
 360         spi_setup(spi);
 361 
 362         return 0;
 363 
 364 err_free_strap:
 365         gpio_free(GPIO19_WLAN_STRAP);
 366 
 367         return err;
 368 }
 369 
 370 static int cm_x270_libertas_teardown(struct spi_device *spi)
 371 {
 372         gpio_set_value(GPIO102_WLAN_RST, 0);
 373         gpio_free(GPIO102_WLAN_RST);
 374         gpio_free(GPIO19_WLAN_STRAP);
 375 
 376         return 0;
 377 }
 378 
 379 struct libertas_spi_platform_data cm_x270_libertas_pdata = {
 380         .use_dummy_writes       = 1,
 381         .setup                  = cm_x270_libertas_setup,
 382         .teardown               = cm_x270_libertas_teardown,
 383 };
 384 
 385 static struct spi_board_info cm_x270_spi_devices[] __initdata = {
 386         {
 387                 .modalias               = "libertas_spi",
 388                 .max_speed_hz           = 13000000,
 389                 .bus_num                = 2,
 390                 .irq                    = PXA_GPIO_TO_IRQ(95),
 391                 .chip_select            = 0,
 392                 .controller_data        = &cm_x270_libertas_chip,
 393                 .platform_data          = &cm_x270_libertas_pdata,
 394         },
 395 };
 396 
 397 static void __init cmx270_init_spi(void)
 398 {
 399         pxa2xx_set_spi_info(2, &cm_x270_spi_info);
 400         spi_register_board_info(ARRAY_AND_SIZE(cm_x270_spi_devices));
 401 }
 402 #else
 403 static inline void cmx270_init_spi(void) {}
 404 #endif
 405 
 406 void __init cmx270_init(void)
 407 {
 408         pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
 409 
 410 #ifdef CONFIG_PM
 411         pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
 412 #endif
 413 
 414         cmx270_init_rtc();
 415         cmx270_init_mmc();
 416         cmx270_init_ohci();
 417         cmx270_init_2700G();
 418         cmx270_init_spi();
 419 }

/* [<][>][^][v][top][bottom][index][help] */