root/arch/arm/mach-davinci/board-omapl138-hawk.c

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

DEFINITIONS

This source file includes following definitions.
  1. omapl138_hawk_config_emac
  2. omapl138_hawk_mmc_init
  3. omapl138_hawk_register_aemif
  4. omapl138_hawk_usb_init
  5. omapl138_hawk_init
  6. omapl138_hawk_console_init
  7. omapl138_hawk_map_io

   1 /*
   2  * Hawkboard.org based on TI's OMAP-L138 Platform
   3  *
   4  * Initial code: Syed Mohammed Khasim
   5  *
   6  * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com
   7  *
   8  * This file is licensed under the terms of the GNU General Public License
   9  * version 2. This program is licensed "as is" without any warranty of
  10  * any kind, whether express or implied.
  11  */
  12 #include <linux/kernel.h>
  13 #include <linux/init.h>
  14 #include <linux/console.h>
  15 #include <linux/interrupt.h>
  16 #include <linux/gpio.h>
  17 #include <linux/gpio/machine.h>
  18 #include <linux/mtd/partitions.h>
  19 #include <linux/mtd/rawnand.h>
  20 #include <linux/platform_data/gpio-davinci.h>
  21 #include <linux/platform_data/mtd-davinci.h>
  22 #include <linux/platform_data/mtd-davinci-aemif.h>
  23 #include <linux/platform_data/ti-aemif.h>
  24 #include <linux/regulator/fixed.h>
  25 #include <linux/regulator/machine.h>
  26 
  27 #include <asm/mach-types.h>
  28 #include <asm/mach/arch.h>
  29 
  30 #include <mach/common.h>
  31 #include <mach/da8xx.h>
  32 #include <mach/mux.h>
  33 
  34 #define HAWKBOARD_PHY_ID                "davinci_mdio-0:07"
  35 
  36 #define DA850_USB1_VBUS_PIN             GPIO_TO_PIN(2, 4)
  37 #define DA850_USB1_OC_PIN               GPIO_TO_PIN(6, 13)
  38 
  39 static short omapl138_hawk_mii_pins[] __initdata = {
  40         DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
  41         DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
  42         DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
  43         DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
  44         DA850_MDIO_D,
  45         -1
  46 };
  47 
  48 static __init void omapl138_hawk_config_emac(void)
  49 {
  50         void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
  51         int ret;
  52         u32 val;
  53         struct davinci_soc_info *soc_info = &davinci_soc_info;
  54 
  55         val = __raw_readl(cfgchip3);
  56         val &= ~BIT(8);
  57         ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins);
  58         if (ret) {
  59                 pr_warn("%s: CPGMAC/MII mux setup failed: %d\n", __func__, ret);
  60                 return;
  61         }
  62 
  63         /* configure the CFGCHIP3 register for MII */
  64         __raw_writel(val, cfgchip3);
  65         pr_info("EMAC: MII PHY configured\n");
  66 
  67         soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID;
  68 
  69         ret = da8xx_register_emac();
  70         if (ret)
  71                 pr_warn("%s: EMAC registration failed: %d\n", __func__, ret);
  72 }
  73 
  74 /*
  75  * The following EDMA channels/slots are not being used by drivers (for
  76  * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM/Hawkboard,
  77  * hence they are being reserved for codecs on the DSP side.
  78  */
  79 static const s16 da850_dma0_rsv_chans[][2] = {
  80         /* (offset, number) */
  81         { 8,  6},
  82         {24,  4},
  83         {30,  2},
  84         {-1, -1}
  85 };
  86 
  87 static const s16 da850_dma0_rsv_slots[][2] = {
  88         /* (offset, number) */
  89         { 8,  6},
  90         {24,  4},
  91         {30, 50},
  92         {-1, -1}
  93 };
  94 
  95 static const s16 da850_dma1_rsv_chans[][2] = {
  96         /* (offset, number) */
  97         { 0, 28},
  98         {30,  2},
  99         {-1, -1}
 100 };
 101 
 102 static const s16 da850_dma1_rsv_slots[][2] = {
 103         /* (offset, number) */
 104         { 0, 28},
 105         {30, 90},
 106         {-1, -1}
 107 };
 108 
 109 static struct edma_rsv_info da850_edma_cc0_rsv = {
 110         .rsv_chans      = da850_dma0_rsv_chans,
 111         .rsv_slots      = da850_dma0_rsv_slots,
 112 };
 113 
 114 static struct edma_rsv_info da850_edma_cc1_rsv = {
 115         .rsv_chans      = da850_dma1_rsv_chans,
 116         .rsv_slots      = da850_dma1_rsv_slots,
 117 };
 118 
 119 static struct edma_rsv_info *da850_edma_rsv[2] = {
 120         &da850_edma_cc0_rsv,
 121         &da850_edma_cc1_rsv,
 122 };
 123 
 124 static const short hawk_mmcsd0_pins[] = {
 125         DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
 126         DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
 127         DA850_GPIO3_12, DA850_GPIO3_13,
 128         -1
 129 };
 130 
 131 #define DA850_HAWK_MMCSD_CD_PIN         GPIO_TO_PIN(3, 12)
 132 #define DA850_HAWK_MMCSD_WP_PIN         GPIO_TO_PIN(3, 13)
 133 
 134 static struct gpiod_lookup_table mmc_gpios_table = {
 135         .dev_id = "da830-mmc.0",
 136         .table = {
 137                 GPIO_LOOKUP("davinci_gpio", DA850_HAWK_MMCSD_CD_PIN, "cd",
 138                             GPIO_ACTIVE_LOW),
 139                 GPIO_LOOKUP("davinci_gpio", DA850_HAWK_MMCSD_WP_PIN, "wp",
 140                             GPIO_ACTIVE_LOW),
 141         },
 142 };
 143 
 144 static struct davinci_mmc_config da850_mmc_config = {
 145         .wires          = 4,
 146         .max_freq       = 50000000,
 147         .caps           = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
 148 };
 149 
 150 static __init void omapl138_hawk_mmc_init(void)
 151 {
 152         int ret;
 153 
 154         ret = davinci_cfg_reg_list(hawk_mmcsd0_pins);
 155         if (ret) {
 156                 pr_warn("%s: MMC/SD0 mux setup failed: %d\n", __func__, ret);
 157                 return;
 158         }
 159 
 160         gpiod_add_lookup_table(&mmc_gpios_table);
 161 
 162         ret = da8xx_register_mmcsd0(&da850_mmc_config);
 163         if (ret) {
 164                 pr_warn("%s: MMC/SD0 registration failed: %d\n", __func__, ret);
 165                 goto mmc_setup_mmcsd_fail;
 166         }
 167 
 168         return;
 169 
 170 mmc_setup_mmcsd_fail:
 171         gpiod_remove_lookup_table(&mmc_gpios_table);
 172 }
 173 
 174 static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
 175         {
 176                 .name           = "u-boot env",
 177                 .offset         = 0,
 178                 .size           = SZ_128K,
 179                 .mask_flags     = MTD_WRITEABLE,
 180          },
 181         {
 182                 .name           = "u-boot",
 183                 .offset         = MTDPART_OFS_APPEND,
 184                 .size           = SZ_512K,
 185                 .mask_flags     = MTD_WRITEABLE,
 186         },
 187         {
 188                 .name           = "free space",
 189                 .offset         = MTDPART_OFS_APPEND,
 190                 .size           = MTDPART_SIZ_FULL,
 191                 .mask_flags     = 0,
 192         },
 193 };
 194 
 195 static struct davinci_aemif_timing omapl138_hawk_nandflash_timing = {
 196         .wsetup         = 24,
 197         .wstrobe        = 21,
 198         .whold          = 14,
 199         .rsetup         = 19,
 200         .rstrobe        = 50,
 201         .rhold          = 0,
 202         .ta             = 20,
 203 };
 204 
 205 static struct davinci_nand_pdata omapl138_hawk_nandflash_data = {
 206         .core_chipsel   = 1,
 207         .parts          = omapl138_hawk_nandflash_partition,
 208         .nr_parts       = ARRAY_SIZE(omapl138_hawk_nandflash_partition),
 209         .ecc_mode       = NAND_ECC_HW,
 210         .ecc_bits       = 4,
 211         .bbt_options    = NAND_BBT_USE_FLASH,
 212         .options        = NAND_BUSWIDTH_16,
 213         .timing         = &omapl138_hawk_nandflash_timing,
 214         .mask_chipsel   = 0,
 215         .mask_ale       = 0,
 216         .mask_cle       = 0,
 217 };
 218 
 219 static struct resource omapl138_hawk_nandflash_resource[] = {
 220         {
 221                 .start  = DA8XX_AEMIF_CS3_BASE,
 222                 .end    = DA8XX_AEMIF_CS3_BASE + SZ_32M,
 223                 .flags  = IORESOURCE_MEM,
 224         },
 225         {
 226                 .start  = DA8XX_AEMIF_CTL_BASE,
 227                 .end    = DA8XX_AEMIF_CTL_BASE + SZ_32K,
 228                 .flags  = IORESOURCE_MEM,
 229         },
 230 };
 231 
 232 static struct resource omapl138_hawk_aemif_resource[] = {
 233         {
 234                 .start  = DA8XX_AEMIF_CTL_BASE,
 235                 .end    = DA8XX_AEMIF_CTL_BASE + SZ_32K,
 236                 .flags  = IORESOURCE_MEM,
 237         }
 238 };
 239 
 240 static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
 241         {
 242                 .cs     = 3,
 243         }
 244 };
 245 
 246 static struct platform_device omapl138_hawk_aemif_devices[] = {
 247         {
 248                 .name           = "davinci_nand",
 249                 .id             = -1,
 250                 .dev            = {
 251                         .platform_data  = &omapl138_hawk_nandflash_data,
 252                 },
 253                 .resource       = omapl138_hawk_nandflash_resource,
 254                 .num_resources  = ARRAY_SIZE(omapl138_hawk_nandflash_resource),
 255         }
 256 };
 257 
 258 static struct aemif_platform_data omapl138_hawk_aemif_pdata = {
 259         .cs_offset = 2,
 260         .abus_data = omapl138_hawk_aemif_abus_data,
 261         .num_abus_data = ARRAY_SIZE(omapl138_hawk_aemif_abus_data),
 262         .sub_devices = omapl138_hawk_aemif_devices,
 263         .num_sub_devices = ARRAY_SIZE(omapl138_hawk_aemif_devices),
 264 };
 265 
 266 static struct platform_device omapl138_hawk_aemif_device = {
 267         .name           = "ti-aemif",
 268         .id             = -1,
 269         .dev = {
 270                 .platform_data  = &omapl138_hawk_aemif_pdata,
 271         },
 272         .resource       = omapl138_hawk_aemif_resource,
 273         .num_resources  = ARRAY_SIZE(omapl138_hawk_aemif_resource),
 274 };
 275 
 276 static const short omapl138_hawk_nand_pins[] = {
 277         DA850_EMA_WAIT_1, DA850_NEMA_OE, DA850_NEMA_WE, DA850_NEMA_CS_3,
 278         DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
 279         DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
 280         DA850_EMA_D_8, DA850_EMA_D_9, DA850_EMA_D_10, DA850_EMA_D_11,
 281         DA850_EMA_D_12, DA850_EMA_D_13, DA850_EMA_D_14, DA850_EMA_D_15,
 282         DA850_EMA_A_1, DA850_EMA_A_2,
 283         -1
 284 };
 285 
 286 static int omapl138_hawk_register_aemif(void)
 287 {
 288         int ret;
 289 
 290         ret = davinci_cfg_reg_list(omapl138_hawk_nand_pins);
 291         if (ret)
 292                 pr_warn("%s: NAND mux setup failed: %d\n", __func__, ret);
 293 
 294         return platform_device_register(&omapl138_hawk_aemif_device);
 295 }
 296 
 297 static const short da850_hawk_usb11_pins[] = {
 298         DA850_GPIO2_4, DA850_GPIO6_13,
 299         -1
 300 };
 301 
 302 static struct regulator_consumer_supply hawk_usb_supplies[] = {
 303         REGULATOR_SUPPLY("vbus", NULL),
 304 };
 305 
 306 static struct regulator_init_data hawk_usb_vbus_data = {
 307         .consumer_supplies      = hawk_usb_supplies,
 308         .num_consumer_supplies  = ARRAY_SIZE(hawk_usb_supplies),
 309         .constraints    = {
 310                 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
 311         },
 312 };
 313 
 314 static struct fixed_voltage_config hawk_usb_vbus = {
 315         .supply_name            = "vbus",
 316         .microvolts             = 3300000,
 317         .init_data              = &hawk_usb_vbus_data,
 318 };
 319 
 320 static struct platform_device hawk_usb_vbus_device = {
 321         .name           = "reg-fixed-voltage",
 322         .id             = 0,
 323         .dev            = {
 324                 .platform_data = &hawk_usb_vbus,
 325         },
 326 };
 327 
 328 static struct gpiod_lookup_table hawk_usb_oc_gpio_lookup = {
 329         .dev_id         = "ohci-da8xx",
 330         .table = {
 331                 GPIO_LOOKUP("davinci_gpio", DA850_USB1_OC_PIN, "oc", 0),
 332                 { }
 333         },
 334 };
 335 
 336 static struct gpiod_lookup_table hawk_usb_vbus_gpio_lookup = {
 337         .dev_id         = "reg-fixed-voltage.0",
 338         .table = {
 339                 GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, NULL, 0),
 340                 { }
 341         },
 342 };
 343 
 344 static struct gpiod_lookup_table *hawk_usb_gpio_lookups[] = {
 345         &hawk_usb_oc_gpio_lookup,
 346         &hawk_usb_vbus_gpio_lookup,
 347 };
 348 
 349 static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {
 350         /* TPS2087 switch @ 5V */
 351         .potpgt         = (3 + 1) / 2,  /* 3 ms max */
 352 };
 353 
 354 static __init void omapl138_hawk_usb_init(void)
 355 {
 356         int ret;
 357 
 358         ret = davinci_cfg_reg_list(da850_hawk_usb11_pins);
 359         if (ret) {
 360                 pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
 361                 return;
 362         }
 363 
 364         ret = da8xx_register_usb_phy_clocks();
 365         if (ret)
 366                 pr_warn("%s: USB PHY CLK registration failed: %d\n",
 367                         __func__, ret);
 368 
 369         gpiod_add_lookup_tables(hawk_usb_gpio_lookups,
 370                                 ARRAY_SIZE(hawk_usb_gpio_lookups));
 371 
 372         ret = da8xx_register_usb_phy();
 373         if (ret)
 374                 pr_warn("%s: USB PHY registration failed: %d\n",
 375                         __func__, ret);
 376 
 377         ret = platform_device_register(&hawk_usb_vbus_device);
 378         if (ret) {
 379                 pr_warn("%s: Unable to register the vbus supply\n", __func__);
 380                 return;
 381         }
 382 
 383         ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata);
 384         if (ret)
 385                 pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
 386 
 387         return;
 388 }
 389 
 390 static __init void omapl138_hawk_init(void)
 391 {
 392         int ret;
 393 
 394         da850_register_clocks();
 395 
 396         ret = da850_register_gpio();
 397         if (ret)
 398                 pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
 399 
 400         davinci_serial_init(da8xx_serial_device);
 401 
 402         omapl138_hawk_config_emac();
 403 
 404         ret = da850_register_edma(da850_edma_rsv);
 405         if (ret)
 406                 pr_warn("%s: EDMA registration failed: %d\n", __func__, ret);
 407 
 408         omapl138_hawk_mmc_init();
 409 
 410         omapl138_hawk_usb_init();
 411 
 412         ret = omapl138_hawk_register_aemif();
 413         if (ret)
 414                 pr_warn("%s: aemif registration failed: %d\n", __func__, ret);
 415 
 416         ret = da8xx_register_watchdog();
 417         if (ret)
 418                 pr_warn("%s: watchdog registration failed: %d\n",
 419                         __func__, ret);
 420 
 421         ret = da8xx_register_rproc();
 422         if (ret)
 423                 pr_warn("%s: dsp/rproc registration failed: %d\n",
 424                         __func__, ret);
 425 
 426         regulator_has_full_constraints();
 427 }
 428 
 429 #ifdef CONFIG_SERIAL_8250_CONSOLE
 430 static int __init omapl138_hawk_console_init(void)
 431 {
 432         if (!machine_is_omapl138_hawkboard())
 433                 return 0;
 434 
 435         return add_preferred_console("ttyS", 2, "115200");
 436 }
 437 console_initcall(omapl138_hawk_console_init);
 438 #endif
 439 
 440 static void __init omapl138_hawk_map_io(void)
 441 {
 442         da850_init();
 443 }
 444 
 445 MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")
 446         .atag_offset    = 0x100,
 447         .map_io         = omapl138_hawk_map_io,
 448         .init_irq       = da850_init_irq,
 449         .init_time      = da850_init_time,
 450         .init_machine   = omapl138_hawk_init,
 451         .init_late      = davinci_init_late,
 452         .dma_zone_size  = SZ_128M,
 453         .reserve        = da8xx_rproc_reserve_cma,
 454 MACHINE_END

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