0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/kernel.h>
0010 #include <linux/init.h>
0011 #include <linux/console.h>
0012 #include <linux/interrupt.h>
0013 #include <linux/gpio.h>
0014 #include <linux/gpio/machine.h>
0015 #include <linux/mtd/partitions.h>
0016 #include <linux/mtd/rawnand.h>
0017 #include <linux/platform_data/gpio-davinci.h>
0018 #include <linux/platform_data/mtd-davinci.h>
0019 #include <linux/platform_data/mtd-davinci-aemif.h>
0020 #include <linux/platform_data/ti-aemif.h>
0021 #include <linux/regulator/fixed.h>
0022 #include <linux/regulator/machine.h>
0023
0024 #include <asm/mach-types.h>
0025 #include <asm/mach/arch.h>
0026
0027 #include "common.h"
0028 #include "da8xx.h"
0029 #include "mux.h"
0030
0031 #define HAWKBOARD_PHY_ID "davinci_mdio-0:07"
0032
0033 #define DA850_USB1_VBUS_PIN GPIO_TO_PIN(2, 4)
0034 #define DA850_USB1_OC_PIN GPIO_TO_PIN(6, 13)
0035
0036 static short omapl138_hawk_mii_pins[] __initdata = {
0037 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
0038 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
0039 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
0040 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
0041 DA850_MDIO_D,
0042 -1
0043 };
0044
0045 static __init void omapl138_hawk_config_emac(void)
0046 {
0047 void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
0048 int ret;
0049 u32 val;
0050 struct davinci_soc_info *soc_info = &davinci_soc_info;
0051
0052 val = __raw_readl(cfgchip3);
0053 val &= ~BIT(8);
0054 ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins);
0055 if (ret) {
0056 pr_warn("%s: CPGMAC/MII mux setup failed: %d\n", __func__, ret);
0057 return;
0058 }
0059
0060
0061 __raw_writel(val, cfgchip3);
0062 pr_info("EMAC: MII PHY configured\n");
0063
0064 soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID;
0065
0066 ret = da8xx_register_emac();
0067 if (ret)
0068 pr_warn("%s: EMAC registration failed: %d\n", __func__, ret);
0069 }
0070
0071
0072
0073
0074
0075
0076 static const s16 da850_dma0_rsv_chans[][2] = {
0077
0078 { 8, 6},
0079 {24, 4},
0080 {30, 2},
0081 {-1, -1}
0082 };
0083
0084 static const s16 da850_dma0_rsv_slots[][2] = {
0085
0086 { 8, 6},
0087 {24, 4},
0088 {30, 50},
0089 {-1, -1}
0090 };
0091
0092 static const s16 da850_dma1_rsv_chans[][2] = {
0093
0094 { 0, 28},
0095 {30, 2},
0096 {-1, -1}
0097 };
0098
0099 static const s16 da850_dma1_rsv_slots[][2] = {
0100
0101 { 0, 28},
0102 {30, 90},
0103 {-1, -1}
0104 };
0105
0106 static struct edma_rsv_info da850_edma_cc0_rsv = {
0107 .rsv_chans = da850_dma0_rsv_chans,
0108 .rsv_slots = da850_dma0_rsv_slots,
0109 };
0110
0111 static struct edma_rsv_info da850_edma_cc1_rsv = {
0112 .rsv_chans = da850_dma1_rsv_chans,
0113 .rsv_slots = da850_dma1_rsv_slots,
0114 };
0115
0116 static struct edma_rsv_info *da850_edma_rsv[2] = {
0117 &da850_edma_cc0_rsv,
0118 &da850_edma_cc1_rsv,
0119 };
0120
0121 static const short hawk_mmcsd0_pins[] = {
0122 DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
0123 DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
0124 DA850_GPIO3_12, DA850_GPIO3_13,
0125 -1
0126 };
0127
0128 #define DA850_HAWK_MMCSD_CD_PIN GPIO_TO_PIN(3, 12)
0129 #define DA850_HAWK_MMCSD_WP_PIN GPIO_TO_PIN(3, 13)
0130
0131 static struct gpiod_lookup_table mmc_gpios_table = {
0132 .dev_id = "da830-mmc.0",
0133 .table = {
0134 GPIO_LOOKUP("davinci_gpio", DA850_HAWK_MMCSD_CD_PIN, "cd",
0135 GPIO_ACTIVE_LOW),
0136 GPIO_LOOKUP("davinci_gpio", DA850_HAWK_MMCSD_WP_PIN, "wp",
0137 GPIO_ACTIVE_LOW),
0138 },
0139 };
0140
0141 static struct davinci_mmc_config da850_mmc_config = {
0142 .wires = 4,
0143 .max_freq = 50000000,
0144 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
0145 };
0146
0147 static __init void omapl138_hawk_mmc_init(void)
0148 {
0149 int ret;
0150
0151 ret = davinci_cfg_reg_list(hawk_mmcsd0_pins);
0152 if (ret) {
0153 pr_warn("%s: MMC/SD0 mux setup failed: %d\n", __func__, ret);
0154 return;
0155 }
0156
0157 gpiod_add_lookup_table(&mmc_gpios_table);
0158
0159 ret = da8xx_register_mmcsd0(&da850_mmc_config);
0160 if (ret) {
0161 pr_warn("%s: MMC/SD0 registration failed: %d\n", __func__, ret);
0162 goto mmc_setup_mmcsd_fail;
0163 }
0164
0165 return;
0166
0167 mmc_setup_mmcsd_fail:
0168 gpiod_remove_lookup_table(&mmc_gpios_table);
0169 }
0170
0171 static struct mtd_partition omapl138_hawk_nandflash_partition[] = {
0172 {
0173 .name = "u-boot env",
0174 .offset = 0,
0175 .size = SZ_128K,
0176 .mask_flags = MTD_WRITEABLE,
0177 },
0178 {
0179 .name = "u-boot",
0180 .offset = MTDPART_OFS_APPEND,
0181 .size = SZ_512K,
0182 .mask_flags = MTD_WRITEABLE,
0183 },
0184 {
0185 .name = "free space",
0186 .offset = MTDPART_OFS_APPEND,
0187 .size = MTDPART_SIZ_FULL,
0188 .mask_flags = 0,
0189 },
0190 };
0191
0192 static struct davinci_aemif_timing omapl138_hawk_nandflash_timing = {
0193 .wsetup = 24,
0194 .wstrobe = 21,
0195 .whold = 14,
0196 .rsetup = 19,
0197 .rstrobe = 50,
0198 .rhold = 0,
0199 .ta = 20,
0200 };
0201
0202 static struct davinci_nand_pdata omapl138_hawk_nandflash_data = {
0203 .core_chipsel = 1,
0204 .parts = omapl138_hawk_nandflash_partition,
0205 .nr_parts = ARRAY_SIZE(omapl138_hawk_nandflash_partition),
0206 .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
0207 .ecc_bits = 4,
0208 .bbt_options = NAND_BBT_USE_FLASH,
0209 .options = NAND_BUSWIDTH_16,
0210 .timing = &omapl138_hawk_nandflash_timing,
0211 .mask_chipsel = 0,
0212 .mask_ale = 0,
0213 .mask_cle = 0,
0214 };
0215
0216 static struct resource omapl138_hawk_nandflash_resource[] = {
0217 {
0218 .start = DA8XX_AEMIF_CS3_BASE,
0219 .end = DA8XX_AEMIF_CS3_BASE + SZ_32M,
0220 .flags = IORESOURCE_MEM,
0221 },
0222 {
0223 .start = DA8XX_AEMIF_CTL_BASE,
0224 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K,
0225 .flags = IORESOURCE_MEM,
0226 },
0227 };
0228
0229 static struct resource omapl138_hawk_aemif_resource[] = {
0230 {
0231 .start = DA8XX_AEMIF_CTL_BASE,
0232 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K,
0233 .flags = IORESOURCE_MEM,
0234 }
0235 };
0236
0237 static struct aemif_abus_data omapl138_hawk_aemif_abus_data[] = {
0238 {
0239 .cs = 3,
0240 }
0241 };
0242
0243 static struct platform_device omapl138_hawk_aemif_devices[] = {
0244 {
0245 .name = "davinci_nand",
0246 .id = -1,
0247 .dev = {
0248 .platform_data = &omapl138_hawk_nandflash_data,
0249 },
0250 .resource = omapl138_hawk_nandflash_resource,
0251 .num_resources = ARRAY_SIZE(omapl138_hawk_nandflash_resource),
0252 }
0253 };
0254
0255 static struct aemif_platform_data omapl138_hawk_aemif_pdata = {
0256 .cs_offset = 2,
0257 .abus_data = omapl138_hawk_aemif_abus_data,
0258 .num_abus_data = ARRAY_SIZE(omapl138_hawk_aemif_abus_data),
0259 .sub_devices = omapl138_hawk_aemif_devices,
0260 .num_sub_devices = ARRAY_SIZE(omapl138_hawk_aemif_devices),
0261 };
0262
0263 static struct platform_device omapl138_hawk_aemif_device = {
0264 .name = "ti-aemif",
0265 .id = -1,
0266 .dev = {
0267 .platform_data = &omapl138_hawk_aemif_pdata,
0268 },
0269 .resource = omapl138_hawk_aemif_resource,
0270 .num_resources = ARRAY_SIZE(omapl138_hawk_aemif_resource),
0271 };
0272
0273 static const short omapl138_hawk_nand_pins[] = {
0274 DA850_EMA_WAIT_1, DA850_NEMA_OE, DA850_NEMA_WE, DA850_NEMA_CS_3,
0275 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
0276 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
0277 DA850_EMA_D_8, DA850_EMA_D_9, DA850_EMA_D_10, DA850_EMA_D_11,
0278 DA850_EMA_D_12, DA850_EMA_D_13, DA850_EMA_D_14, DA850_EMA_D_15,
0279 DA850_EMA_A_1, DA850_EMA_A_2,
0280 -1
0281 };
0282
0283 static int omapl138_hawk_register_aemif(void)
0284 {
0285 int ret;
0286
0287 ret = davinci_cfg_reg_list(omapl138_hawk_nand_pins);
0288 if (ret)
0289 pr_warn("%s: NAND mux setup failed: %d\n", __func__, ret);
0290
0291 return platform_device_register(&omapl138_hawk_aemif_device);
0292 }
0293
0294 static const short da850_hawk_usb11_pins[] = {
0295 DA850_GPIO2_4, DA850_GPIO6_13,
0296 -1
0297 };
0298
0299 static struct regulator_consumer_supply hawk_usb_supplies[] = {
0300 REGULATOR_SUPPLY("vbus", NULL),
0301 };
0302
0303 static struct regulator_init_data hawk_usb_vbus_data = {
0304 .consumer_supplies = hawk_usb_supplies,
0305 .num_consumer_supplies = ARRAY_SIZE(hawk_usb_supplies),
0306 .constraints = {
0307 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
0308 },
0309 };
0310
0311 static struct fixed_voltage_config hawk_usb_vbus = {
0312 .supply_name = "vbus",
0313 .microvolts = 3300000,
0314 .init_data = &hawk_usb_vbus_data,
0315 };
0316
0317 static struct platform_device hawk_usb_vbus_device = {
0318 .name = "reg-fixed-voltage",
0319 .id = 0,
0320 .dev = {
0321 .platform_data = &hawk_usb_vbus,
0322 },
0323 };
0324
0325 static struct gpiod_lookup_table hawk_usb_oc_gpio_lookup = {
0326 .dev_id = "ohci-da8xx",
0327 .table = {
0328 GPIO_LOOKUP("davinci_gpio", DA850_USB1_OC_PIN, "oc", 0),
0329 { }
0330 },
0331 };
0332
0333 static struct gpiod_lookup_table hawk_usb_vbus_gpio_lookup = {
0334 .dev_id = "reg-fixed-voltage.0",
0335 .table = {
0336 GPIO_LOOKUP("davinci_gpio", DA850_USB1_VBUS_PIN, NULL, 0),
0337 { }
0338 },
0339 };
0340
0341 static struct gpiod_lookup_table *hawk_usb_gpio_lookups[] = {
0342 &hawk_usb_oc_gpio_lookup,
0343 &hawk_usb_vbus_gpio_lookup,
0344 };
0345
0346 static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {
0347
0348 .potpgt = (3 + 1) / 2,
0349 };
0350
0351 static __init void omapl138_hawk_usb_init(void)
0352 {
0353 int ret;
0354
0355 ret = davinci_cfg_reg_list(da850_hawk_usb11_pins);
0356 if (ret) {
0357 pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
0358 return;
0359 }
0360
0361 ret = da8xx_register_usb_phy_clocks();
0362 if (ret)
0363 pr_warn("%s: USB PHY CLK registration failed: %d\n",
0364 __func__, ret);
0365
0366 gpiod_add_lookup_tables(hawk_usb_gpio_lookups,
0367 ARRAY_SIZE(hawk_usb_gpio_lookups));
0368
0369 ret = da8xx_register_usb_phy();
0370 if (ret)
0371 pr_warn("%s: USB PHY registration failed: %d\n",
0372 __func__, ret);
0373
0374 ret = platform_device_register(&hawk_usb_vbus_device);
0375 if (ret) {
0376 pr_warn("%s: Unable to register the vbus supply\n", __func__);
0377 return;
0378 }
0379
0380 ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata);
0381 if (ret)
0382 pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
0383
0384 return;
0385 }
0386
0387 static __init void omapl138_hawk_init(void)
0388 {
0389 int ret;
0390
0391 da850_register_clocks();
0392
0393 ret = da850_register_gpio();
0394 if (ret)
0395 pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
0396
0397 davinci_serial_init(da8xx_serial_device);
0398
0399 omapl138_hawk_config_emac();
0400
0401 ret = da850_register_edma(da850_edma_rsv);
0402 if (ret)
0403 pr_warn("%s: EDMA registration failed: %d\n", __func__, ret);
0404
0405 omapl138_hawk_mmc_init();
0406
0407 omapl138_hawk_usb_init();
0408
0409 ret = omapl138_hawk_register_aemif();
0410 if (ret)
0411 pr_warn("%s: aemif registration failed: %d\n", __func__, ret);
0412
0413 ret = da8xx_register_watchdog();
0414 if (ret)
0415 pr_warn("%s: watchdog registration failed: %d\n",
0416 __func__, ret);
0417
0418 ret = da8xx_register_rproc();
0419 if (ret)
0420 pr_warn("%s: dsp/rproc registration failed: %d\n",
0421 __func__, ret);
0422
0423 regulator_has_full_constraints();
0424 }
0425
0426 #ifdef CONFIG_SERIAL_8250_CONSOLE
0427 static int __init omapl138_hawk_console_init(void)
0428 {
0429 if (!machine_is_omapl138_hawkboard())
0430 return 0;
0431
0432 return add_preferred_console("ttyS", 2, "115200");
0433 }
0434 console_initcall(omapl138_hawk_console_init);
0435 #endif
0436
0437 static void __init omapl138_hawk_map_io(void)
0438 {
0439 da850_init();
0440 }
0441
0442 MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard")
0443 .atag_offset = 0x100,
0444 .map_io = omapl138_hawk_map_io,
0445 .init_irq = da850_init_irq,
0446 .init_time = da850_init_time,
0447 .init_machine = omapl138_hawk_init,
0448 .init_late = davinci_init_late,
0449 .dma_zone_size = SZ_128M,
0450 .reserve = da8xx_rproc_reserve_cma,
0451 MACHINE_END