hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/arm/mach-davinci/board-da850-evm.c
....@@ -1,7 +1,7 @@
11 /*
22 * TI DA850/OMAP-L138 EVM board
33 *
4
- * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
4
+ * Copyright (C) 2009 Texas Instruments Incorporated - https://www.ti.com/
55 *
66 * Derived from: arch/arm/mach-davinci/board-da830-evm.c
77 * Original Copyrights follow:
....@@ -20,7 +20,6 @@
2020 #include <linux/kernel.h>
2121 #include <linux/leds.h>
2222 #include <linux/i2c.h>
23
-#include <linux/platform_data/at24.h>
2423 #include <linux/platform_data/pca953x.h>
2524 #include <linux/input.h>
2625 #include <linux/input/tps6507x-ts.h>
....@@ -28,6 +27,7 @@
2827 #include <linux/mtd/mtd.h>
2928 #include <linux/mtd/rawnand.h>
3029 #include <linux/mtd/partitions.h>
30
+#include <linux/nvmem-provider.h>
3131 #include <linux/mtd/physmap.h>
3232 #include <linux/platform_device.h>
3333 #include <linux/platform_data/gpio-davinci.h>
....@@ -36,6 +36,7 @@
3636 #include <linux/platform_data/ti-aemif.h>
3737 #include <linux/platform_data/spi-davinci.h>
3838 #include <linux/platform_data/uio_pruss.h>
39
+#include <linux/property.h>
3940 #include <linux/regulator/machine.h>
4041 #include <linux/regulator/tps6507x.h>
4142 #include <linux/regulator/fixed.h>
....@@ -43,9 +44,10 @@
4344 #include <linux/spi/flash.h>
4445
4546 #include <mach/common.h>
46
-#include "cp_intc.h"
4747 #include <mach/da8xx.h>
4848 #include <mach/mux.h>
49
+
50
+#include "irqs.h"
4951 #include "sram.h"
5052
5153 #include <asm/mach-types.h>
....@@ -100,6 +102,31 @@
100102 },
101103 };
102104
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
+
103130 static struct flash_platform_data da850evm_spiflash_data = {
104131 .name = "m25p80",
105132 .parts = da850evm_spiflash_part,
....@@ -124,32 +151,6 @@
124151 .chip_select = 0,
125152 },
126153 };
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
153154
154155 static struct mtd_partition da850_evm_norflash_partition[] = {
155156 {
....@@ -238,7 +239,7 @@
238239 .core_chipsel = 1,
239240 .parts = da850_evm_nandflash_partition,
240241 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
241
- .ecc_mode = NAND_ECC_HW,
242
+ .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
242243 .ecc_bits = 4,
243244 .bbt_options = NAND_BBT_USE_FLASH,
244245 .timing = &da850_evm_nandflash_timing,
....@@ -631,19 +632,32 @@
631632 }
632633 }
633634
634
-#define DA850_N_BB_USER_LED 2
635
-
636635 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",
641641 },
642642 };
643643
644644 static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
645645 .leds = da850_evm_bb_leds,
646646 .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
+ },
647661 };
648662
649663 static struct platform_device da850_evm_bb_leds_device = {
....@@ -653,20 +667,6 @@
653667 .platform_data = &da850_evm_bb_leds_pdata
654668 }
655669 };
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
-}
670670
671671 static int da850_evm_bb_expander_setup(struct i2c_client *client,
672672 unsigned gpio, unsigned ngpio,
....@@ -685,7 +685,7 @@
685685 goto io_exp_setup_sw_fail;
686686 }
687687
688
- da850_evm_bb_leds_init(gpio);
688
+ gpiod_add_lookup_table(&da850_evm_bb_leds_gpio_table);
689689 ret = platform_device_register(&da850_evm_bb_leds_device);
690690 if (ret) {
691691 pr_warn("Could not register baseboard GPIO expander LEDs");
....@@ -729,10 +729,12 @@
729729 },
730730 {
731731 I2C_BOARD_INFO("tca6416", 0x20),
732
+ .dev_name = "ui-expander",
732733 .platform_data = &da850_evm_ui_expander_info,
733734 },
734735 {
735736 I2C_BOARD_INFO("tca6416", 0x21),
737
+ .dev_name = "bb-expander",
736738 .platform_data = &da850_evm_bb_expander_info,
737739 },
738740 };
....@@ -780,10 +782,11 @@
780782 .dev_id = "da830-mmc.0",
781783 .table = {
782784 /* 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",
784786 GPIO_ACTIVE_LOW),
785
- GPIO_LOOKUP("davinci_gpio.0", DA850_MMCSD_WP_PIN, "wp",
787
+ GPIO_LOOKUP("davinci_gpio", DA850_MMCSD_WP_PIN, "wp",
786788 GPIO_ACTIVE_HIGH),
789
+ { }
787790 },
788791 };
789792
....@@ -800,37 +803,79 @@
800803 -1
801804 };
802805
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
+};
807810
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
+};
811863
812864 static int da850_lcd_hw_init(void)
813865 {
866
+ struct platform_device *backlight;
814867 int status;
815868
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)
818878 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);
834879
835880 return 0;
836881 }
....@@ -1039,16 +1084,29 @@
10391084 -1
10401085 };
10411086
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
+
10421098 static int __init da850_evm_config_emac(void)
10431099 {
10441100 void __iomem *cfg_chip3_base;
10451101 int ret;
10461102 u32 val;
10471103 struct davinci_soc_info *soc_info = &davinci_soc_info;
1048
- u8 rmii_en = soc_info->emac_pdata->rmii_en;
1104
+ u8 rmii_en;
10491105
10501106 if (!machine_is_davinci_da850_evm())
10511107 return 0;
1108
+
1109
+ rmii_en = soc_info->emac_pdata->rmii_en;
10521110
10531111 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
10541112
....@@ -1077,14 +1135,9 @@
10771135 if (ret)
10781136 pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__);
10791137
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);
10881141
10891142 soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
10901143
....@@ -1395,6 +1448,9 @@
13951448
13961449 davinci_serial_init(da8xx_serial_device);
13971450
1451
+ nvmem_add_cell_table(&da850evm_nvmem_cell_table);
1452
+ nvmem_add_cell_lookups(&da850evm_nvmem_cell_lookup, 1);
1453
+
13981454 i2c_register_board_info(1, da850_evm_i2c_devices,
13991455 ARRAY_SIZE(da850_evm_i2c_devices));
14001456
....@@ -1432,7 +1488,6 @@
14321488 if (ret)
14331489 pr_warn("%s: LCD initialization failed: %d\n", __func__, ret);
14341490
1435
- sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
14361491 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
14371492 if (ret)
14381493 pr_warn("%s: LCDC registration failed: %d\n", __func__, ret);
....@@ -1466,8 +1521,6 @@
14661521 if (ret)
14671522 pr_warn("%s: SATA registration failed: %d\n", __func__, ret);
14681523
1469
- da850_evm_setup_mac_addr();
1470
-
14711524 ret = da8xx_register_rproc();
14721525 if (ret)
14731526 pr_warn("%s: dsp/rproc registration failed: %d\n",
....@@ -1495,7 +1548,7 @@
14951548 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
14961549 .atag_offset = 0x100,
14971550 .map_io = da850_evm_map_io,
1498
- .init_irq = cp_intc_init,
1551
+ .init_irq = da850_init_irq,
14991552 .init_time = da850_init_time,
15001553 .init_machine = da850_evm_init,
15011554 .init_late = davinci_init_late,