.. | .. |
---|
1 | 1 | /* |
---|
2 | 2 | * TI DA850/OMAP-L138 EVM board |
---|
3 | 3 | * |
---|
4 | | - * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ |
---|
| 4 | + * Copyright (C) 2009 Texas Instruments Incorporated - https://www.ti.com/ |
---|
5 | 5 | * |
---|
6 | 6 | * Derived from: arch/arm/mach-davinci/board-da830-evm.c |
---|
7 | 7 | * Original Copyrights follow: |
---|
.. | .. |
---|
20 | 20 | #include <linux/kernel.h> |
---|
21 | 21 | #include <linux/leds.h> |
---|
22 | 22 | #include <linux/i2c.h> |
---|
23 | | -#include <linux/platform_data/at24.h> |
---|
24 | 23 | #include <linux/platform_data/pca953x.h> |
---|
25 | 24 | #include <linux/input.h> |
---|
26 | 25 | #include <linux/input/tps6507x-ts.h> |
---|
.. | .. |
---|
28 | 27 | #include <linux/mtd/mtd.h> |
---|
29 | 28 | #include <linux/mtd/rawnand.h> |
---|
30 | 29 | #include <linux/mtd/partitions.h> |
---|
| 30 | +#include <linux/nvmem-provider.h> |
---|
31 | 31 | #include <linux/mtd/physmap.h> |
---|
32 | 32 | #include <linux/platform_device.h> |
---|
33 | 33 | #include <linux/platform_data/gpio-davinci.h> |
---|
.. | .. |
---|
36 | 36 | #include <linux/platform_data/ti-aemif.h> |
---|
37 | 37 | #include <linux/platform_data/spi-davinci.h> |
---|
38 | 38 | #include <linux/platform_data/uio_pruss.h> |
---|
| 39 | +#include <linux/property.h> |
---|
39 | 40 | #include <linux/regulator/machine.h> |
---|
40 | 41 | #include <linux/regulator/tps6507x.h> |
---|
41 | 42 | #include <linux/regulator/fixed.h> |
---|
.. | .. |
---|
43 | 44 | #include <linux/spi/flash.h> |
---|
44 | 45 | |
---|
45 | 46 | #include <mach/common.h> |
---|
46 | | -#include "cp_intc.h" |
---|
47 | 47 | #include <mach/da8xx.h> |
---|
48 | 48 | #include <mach/mux.h> |
---|
| 49 | + |
---|
| 50 | +#include "irqs.h" |
---|
49 | 51 | #include "sram.h" |
---|
50 | 52 | |
---|
51 | 53 | #include <asm/mach-types.h> |
---|
.. | .. |
---|
100 | 102 | }, |
---|
101 | 103 | }; |
---|
102 | 104 | |
---|
| 105 | +static struct nvmem_cell_info da850evm_nvmem_cells[] = { |
---|
| 106 | + { |
---|
| 107 | + .name = "macaddr", |
---|
| 108 | + .offset = 0x0, |
---|
| 109 | + .bytes = ETH_ALEN, |
---|
| 110 | + } |
---|
| 111 | +}; |
---|
| 112 | + |
---|
| 113 | +static struct nvmem_cell_table da850evm_nvmem_cell_table = { |
---|
| 114 | + /* |
---|
| 115 | + * The nvmem name differs from the partition name because of the |
---|
| 116 | + * internal works of the nvmem framework. |
---|
| 117 | + */ |
---|
| 118 | + .nvmem_name = "MAC-Address0", |
---|
| 119 | + .cells = da850evm_nvmem_cells, |
---|
| 120 | + .ncells = ARRAY_SIZE(da850evm_nvmem_cells), |
---|
| 121 | +}; |
---|
| 122 | + |
---|
| 123 | +static struct nvmem_cell_lookup da850evm_nvmem_cell_lookup = { |
---|
| 124 | + .nvmem_name = "MAC-Address0", |
---|
| 125 | + .cell_name = "macaddr", |
---|
| 126 | + .dev_id = "davinci_emac.1", |
---|
| 127 | + .con_id = "mac-address", |
---|
| 128 | +}; |
---|
| 129 | + |
---|
103 | 130 | static struct flash_platform_data da850evm_spiflash_data = { |
---|
104 | 131 | .name = "m25p80", |
---|
105 | 132 | .parts = da850evm_spiflash_part, |
---|
.. | .. |
---|
124 | 151 | .chip_select = 0, |
---|
125 | 152 | }, |
---|
126 | 153 | }; |
---|
127 | | - |
---|
128 | | -#ifdef CONFIG_MTD |
---|
129 | | -static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) |
---|
130 | | -{ |
---|
131 | | - char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; |
---|
132 | | - size_t retlen; |
---|
133 | | - |
---|
134 | | - if (!strcmp(mtd->name, "MAC-Address")) { |
---|
135 | | - mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr); |
---|
136 | | - if (retlen == ETH_ALEN) |
---|
137 | | - pr_info("Read MAC addr from SPI Flash: %pM\n", |
---|
138 | | - mac_addr); |
---|
139 | | - } |
---|
140 | | -} |
---|
141 | | - |
---|
142 | | -static struct mtd_notifier da850evm_spi_notifier = { |
---|
143 | | - .add = da850_evm_m25p80_notify_add, |
---|
144 | | -}; |
---|
145 | | - |
---|
146 | | -static void da850_evm_setup_mac_addr(void) |
---|
147 | | -{ |
---|
148 | | - register_mtd_user(&da850evm_spi_notifier); |
---|
149 | | -} |
---|
150 | | -#else |
---|
151 | | -static void da850_evm_setup_mac_addr(void) { } |
---|
152 | | -#endif |
---|
153 | 154 | |
---|
154 | 155 | static struct mtd_partition da850_evm_norflash_partition[] = { |
---|
155 | 156 | { |
---|
.. | .. |
---|
238 | 239 | .core_chipsel = 1, |
---|
239 | 240 | .parts = da850_evm_nandflash_partition, |
---|
240 | 241 | .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition), |
---|
241 | | - .ecc_mode = NAND_ECC_HW, |
---|
| 242 | + .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST, |
---|
242 | 243 | .ecc_bits = 4, |
---|
243 | 244 | .bbt_options = NAND_BBT_USE_FLASH, |
---|
244 | 245 | .timing = &da850_evm_nandflash_timing, |
---|
.. | .. |
---|
631 | 632 | } |
---|
632 | 633 | } |
---|
633 | 634 | |
---|
634 | | -#define DA850_N_BB_USER_LED 2 |
---|
635 | | - |
---|
636 | 635 | static struct gpio_led da850_evm_bb_leds[] = { |
---|
637 | | - [0 ... DA850_N_BB_USER_LED - 1] = { |
---|
638 | | - .active_low = 1, |
---|
639 | | - .gpio = -1, /* assigned at runtime */ |
---|
640 | | - .name = NULL, /* assigned at runtime */ |
---|
| 636 | + { |
---|
| 637 | + .name = "user_led2", |
---|
| 638 | + }, |
---|
| 639 | + { |
---|
| 640 | + .name = "user_led1", |
---|
641 | 641 | }, |
---|
642 | 642 | }; |
---|
643 | 643 | |
---|
644 | 644 | static struct gpio_led_platform_data da850_evm_bb_leds_pdata = { |
---|
645 | 645 | .leds = da850_evm_bb_leds, |
---|
646 | 646 | .num_leds = ARRAY_SIZE(da850_evm_bb_leds), |
---|
| 647 | +}; |
---|
| 648 | + |
---|
| 649 | +static struct gpiod_lookup_table da850_evm_bb_leds_gpio_table = { |
---|
| 650 | + .dev_id = "leds-gpio", |
---|
| 651 | + .table = { |
---|
| 652 | + GPIO_LOOKUP_IDX("i2c-bb-expander", |
---|
| 653 | + DA850_EVM_BB_EXP_USER_LED2, NULL, |
---|
| 654 | + 0, GPIO_ACTIVE_LOW), |
---|
| 655 | + GPIO_LOOKUP_IDX("i2c-bb-expander", |
---|
| 656 | + DA850_EVM_BB_EXP_USER_LED2 + 1, NULL, |
---|
| 657 | + 1, GPIO_ACTIVE_LOW), |
---|
| 658 | + |
---|
| 659 | + { }, |
---|
| 660 | + }, |
---|
647 | 661 | }; |
---|
648 | 662 | |
---|
649 | 663 | static struct platform_device da850_evm_bb_leds_device = { |
---|
.. | .. |
---|
653 | 667 | .platform_data = &da850_evm_bb_leds_pdata |
---|
654 | 668 | } |
---|
655 | 669 | }; |
---|
656 | | - |
---|
657 | | -static void da850_evm_bb_leds_init(unsigned gpio) |
---|
658 | | -{ |
---|
659 | | - int i; |
---|
660 | | - struct gpio_led *led; |
---|
661 | | - |
---|
662 | | - for (i = 0; i < DA850_N_BB_USER_LED; i++) { |
---|
663 | | - led = &da850_evm_bb_leds[i]; |
---|
664 | | - |
---|
665 | | - led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i; |
---|
666 | | - led->name = |
---|
667 | | - da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i]; |
---|
668 | | - } |
---|
669 | | -} |
---|
670 | 670 | |
---|
671 | 671 | static int da850_evm_bb_expander_setup(struct i2c_client *client, |
---|
672 | 672 | unsigned gpio, unsigned ngpio, |
---|
.. | .. |
---|
685 | 685 | goto io_exp_setup_sw_fail; |
---|
686 | 686 | } |
---|
687 | 687 | |
---|
688 | | - da850_evm_bb_leds_init(gpio); |
---|
| 688 | + gpiod_add_lookup_table(&da850_evm_bb_leds_gpio_table); |
---|
689 | 689 | ret = platform_device_register(&da850_evm_bb_leds_device); |
---|
690 | 690 | if (ret) { |
---|
691 | 691 | pr_warn("Could not register baseboard GPIO expander LEDs"); |
---|
.. | .. |
---|
729 | 729 | }, |
---|
730 | 730 | { |
---|
731 | 731 | I2C_BOARD_INFO("tca6416", 0x20), |
---|
| 732 | + .dev_name = "ui-expander", |
---|
732 | 733 | .platform_data = &da850_evm_ui_expander_info, |
---|
733 | 734 | }, |
---|
734 | 735 | { |
---|
735 | 736 | I2C_BOARD_INFO("tca6416", 0x21), |
---|
| 737 | + .dev_name = "bb-expander", |
---|
736 | 738 | .platform_data = &da850_evm_bb_expander_info, |
---|
737 | 739 | }, |
---|
738 | 740 | }; |
---|
.. | .. |
---|
780 | 782 | .dev_id = "da830-mmc.0", |
---|
781 | 783 | .table = { |
---|
782 | 784 | /* gpio chip 2 contains gpio range 64-95 */ |
---|
783 | | - GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_CD_PIN, "cd", |
---|
| 785 | + GPIO_LOOKUP("davinci_gpio", DA850_MMCSD_CD_PIN, "cd", |
---|
784 | 786 | GPIO_ACTIVE_LOW), |
---|
785 | | - GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp", |
---|
| 787 | + GPIO_LOOKUP("davinci_gpio", DA850_MMCSD_WP_PIN, "wp", |
---|
786 | 788 | GPIO_ACTIVE_HIGH), |
---|
| 789 | + { } |
---|
787 | 790 | }, |
---|
788 | 791 | }; |
---|
789 | 792 | |
---|
.. | .. |
---|
800 | 803 | -1 |
---|
801 | 804 | }; |
---|
802 | 805 | |
---|
803 | | -static void da850_panel_power_ctrl(int val) |
---|
804 | | -{ |
---|
805 | | - /* lcd backlight */ |
---|
806 | | - gpio_set_value(DA850_LCD_BL_PIN, val); |
---|
| 806 | +static struct property_entry da850_lcd_backlight_props[] = { |
---|
| 807 | + PROPERTY_ENTRY_BOOL("default-on"), |
---|
| 808 | + { } |
---|
| 809 | +}; |
---|
807 | 810 | |
---|
808 | | - /* lcd power */ |
---|
809 | | - gpio_set_value(DA850_LCD_PWR_PIN, val); |
---|
810 | | -} |
---|
| 811 | +static struct gpiod_lookup_table da850_lcd_backlight_gpio_table = { |
---|
| 812 | + .dev_id = "gpio-backlight", |
---|
| 813 | + .table = { |
---|
| 814 | + GPIO_LOOKUP("davinci_gpio", DA850_LCD_BL_PIN, NULL, 0), |
---|
| 815 | + { } |
---|
| 816 | + }, |
---|
| 817 | +}; |
---|
| 818 | + |
---|
| 819 | +static const struct platform_device_info da850_lcd_backlight_info = { |
---|
| 820 | + .name = "gpio-backlight", |
---|
| 821 | + .id = PLATFORM_DEVID_NONE, |
---|
| 822 | + .properties = da850_lcd_backlight_props, |
---|
| 823 | +}; |
---|
| 824 | + |
---|
| 825 | +static struct regulator_consumer_supply da850_lcd_supplies[] = { |
---|
| 826 | + REGULATOR_SUPPLY("lcd", NULL), |
---|
| 827 | +}; |
---|
| 828 | + |
---|
| 829 | +static struct regulator_init_data da850_lcd_supply_data = { |
---|
| 830 | + .consumer_supplies = da850_lcd_supplies, |
---|
| 831 | + .num_consumer_supplies = ARRAY_SIZE(da850_lcd_supplies), |
---|
| 832 | + .constraints = { |
---|
| 833 | + .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
---|
| 834 | + }, |
---|
| 835 | +}; |
---|
| 836 | + |
---|
| 837 | +static struct fixed_voltage_config da850_lcd_supply = { |
---|
| 838 | + .supply_name = "lcd", |
---|
| 839 | + .microvolts = 33000000, |
---|
| 840 | + .init_data = &da850_lcd_supply_data, |
---|
| 841 | +}; |
---|
| 842 | + |
---|
| 843 | +static struct platform_device da850_lcd_supply_device = { |
---|
| 844 | + .name = "reg-fixed-voltage", |
---|
| 845 | + .id = 1, /* Dummy fixed regulator is 0 */ |
---|
| 846 | + .dev = { |
---|
| 847 | + .platform_data = &da850_lcd_supply, |
---|
| 848 | + }, |
---|
| 849 | +}; |
---|
| 850 | + |
---|
| 851 | +static struct gpiod_lookup_table da850_lcd_supply_gpio_table = { |
---|
| 852 | + .dev_id = "reg-fixed-voltage.1", |
---|
| 853 | + .table = { |
---|
| 854 | + GPIO_LOOKUP("davinci_gpio", DA850_LCD_PWR_PIN, NULL, 0), |
---|
| 855 | + { } |
---|
| 856 | + }, |
---|
| 857 | +}; |
---|
| 858 | + |
---|
| 859 | +static struct gpiod_lookup_table *da850_lcd_gpio_lookups[] = { |
---|
| 860 | + &da850_lcd_backlight_gpio_table, |
---|
| 861 | + &da850_lcd_supply_gpio_table, |
---|
| 862 | +}; |
---|
811 | 863 | |
---|
812 | 864 | static int da850_lcd_hw_init(void) |
---|
813 | 865 | { |
---|
| 866 | + struct platform_device *backlight; |
---|
814 | 867 | int status; |
---|
815 | 868 | |
---|
816 | | - status = gpio_request(DA850_LCD_BL_PIN, "lcd bl"); |
---|
817 | | - if (status < 0) |
---|
| 869 | + gpiod_add_lookup_tables(da850_lcd_gpio_lookups, |
---|
| 870 | + ARRAY_SIZE(da850_lcd_gpio_lookups)); |
---|
| 871 | + |
---|
| 872 | + backlight = platform_device_register_full(&da850_lcd_backlight_info); |
---|
| 873 | + if (IS_ERR(backlight)) |
---|
| 874 | + return PTR_ERR(backlight); |
---|
| 875 | + |
---|
| 876 | + status = platform_device_register(&da850_lcd_supply_device); |
---|
| 877 | + if (status) |
---|
818 | 878 | return status; |
---|
819 | | - |
---|
820 | | - status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr"); |
---|
821 | | - if (status < 0) { |
---|
822 | | - gpio_free(DA850_LCD_BL_PIN); |
---|
823 | | - return status; |
---|
824 | | - } |
---|
825 | | - |
---|
826 | | - gpio_direction_output(DA850_LCD_BL_PIN, 0); |
---|
827 | | - gpio_direction_output(DA850_LCD_PWR_PIN, 0); |
---|
828 | | - |
---|
829 | | - /* Switch off panel power and backlight */ |
---|
830 | | - da850_panel_power_ctrl(0); |
---|
831 | | - |
---|
832 | | - /* Switch on panel power and backlight */ |
---|
833 | | - da850_panel_power_ctrl(1); |
---|
834 | 879 | |
---|
835 | 880 | return 0; |
---|
836 | 881 | } |
---|
.. | .. |
---|
1039 | 1084 | -1 |
---|
1040 | 1085 | }; |
---|
1041 | 1086 | |
---|
| 1087 | +static struct gpiod_hog da850_evm_emac_gpio_hogs[] = { |
---|
| 1088 | + { |
---|
| 1089 | + .chip_label = "davinci_gpio", |
---|
| 1090 | + .chip_hwnum = DA850_MII_MDIO_CLKEN_PIN, |
---|
| 1091 | + .line_name = "mdio_clk_en", |
---|
| 1092 | + .lflags = 0, |
---|
| 1093 | + /* dflags set in da850_evm_config_emac() */ |
---|
| 1094 | + }, |
---|
| 1095 | + { } |
---|
| 1096 | +}; |
---|
| 1097 | + |
---|
1042 | 1098 | static int __init da850_evm_config_emac(void) |
---|
1043 | 1099 | { |
---|
1044 | 1100 | void __iomem *cfg_chip3_base; |
---|
1045 | 1101 | int ret; |
---|
1046 | 1102 | u32 val; |
---|
1047 | 1103 | struct davinci_soc_info *soc_info = &davinci_soc_info; |
---|
1048 | | - u8 rmii_en = soc_info->emac_pdata->rmii_en; |
---|
| 1104 | + u8 rmii_en; |
---|
1049 | 1105 | |
---|
1050 | 1106 | if (!machine_is_davinci_da850_evm()) |
---|
1051 | 1107 | return 0; |
---|
| 1108 | + |
---|
| 1109 | + rmii_en = soc_info->emac_pdata->rmii_en; |
---|
1052 | 1110 | |
---|
1053 | 1111 | cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); |
---|
1054 | 1112 | |
---|
.. | .. |
---|
1077 | 1135 | if (ret) |
---|
1078 | 1136 | pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__); |
---|
1079 | 1137 | |
---|
1080 | | - ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en"); |
---|
1081 | | - if (ret) { |
---|
1082 | | - pr_warn("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN); |
---|
1083 | | - return ret; |
---|
1084 | | - } |
---|
1085 | | - |
---|
1086 | | - /* Enable/Disable MII MDIO clock */ |
---|
1087 | | - gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en); |
---|
| 1138 | + da850_evm_emac_gpio_hogs[0].dflags = rmii_en ? GPIOD_OUT_HIGH |
---|
| 1139 | + : GPIOD_OUT_LOW; |
---|
| 1140 | + gpiod_add_hogs(da850_evm_emac_gpio_hogs); |
---|
1088 | 1141 | |
---|
1089 | 1142 | soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID; |
---|
1090 | 1143 | |
---|
.. | .. |
---|
1395 | 1448 | |
---|
1396 | 1449 | davinci_serial_init(da8xx_serial_device); |
---|
1397 | 1450 | |
---|
| 1451 | + nvmem_add_cell_table(&da850evm_nvmem_cell_table); |
---|
| 1452 | + nvmem_add_cell_lookups(&da850evm_nvmem_cell_lookup, 1); |
---|
| 1453 | + |
---|
1398 | 1454 | i2c_register_board_info(1, da850_evm_i2c_devices, |
---|
1399 | 1455 | ARRAY_SIZE(da850_evm_i2c_devices)); |
---|
1400 | 1456 | |
---|
.. | .. |
---|
1432 | 1488 | if (ret) |
---|
1433 | 1489 | pr_warn("%s: LCD initialization failed: %d\n", __func__, ret); |
---|
1434 | 1490 | |
---|
1435 | | - sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl, |
---|
1436 | 1491 | ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata); |
---|
1437 | 1492 | if (ret) |
---|
1438 | 1493 | pr_warn("%s: LCDC registration failed: %d\n", __func__, ret); |
---|
.. | .. |
---|
1466 | 1521 | if (ret) |
---|
1467 | 1522 | pr_warn("%s: SATA registration failed: %d\n", __func__, ret); |
---|
1468 | 1523 | |
---|
1469 | | - da850_evm_setup_mac_addr(); |
---|
1470 | | - |
---|
1471 | 1524 | ret = da8xx_register_rproc(); |
---|
1472 | 1525 | if (ret) |
---|
1473 | 1526 | pr_warn("%s: dsp/rproc registration failed: %d\n", |
---|
.. | .. |
---|
1495 | 1548 | MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM") |
---|
1496 | 1549 | .atag_offset = 0x100, |
---|
1497 | 1550 | .map_io = da850_evm_map_io, |
---|
1498 | | - .init_irq = cp_intc_init, |
---|
| 1551 | + .init_irq = da850_init_irq, |
---|
1499 | 1552 | .init_time = da850_init_time, |
---|
1500 | 1553 | .init_machine = da850_evm_init, |
---|
1501 | 1554 | .init_late = davinci_init_late, |
---|