forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/mach-davinci/board-dm644x-evm.c
....@@ -16,18 +16,21 @@
1616 #include <linux/gpio/machine.h>
1717 #include <linux/i2c.h>
1818 #include <linux/platform_data/pcf857x.h>
19
-#include <linux/platform_data/at24.h>
2019 #include <linux/platform_data/gpio-davinci.h>
20
+#include <linux/property.h>
2121 #include <linux/mtd/mtd.h>
2222 #include <linux/mtd/rawnand.h>
2323 #include <linux/mtd/partitions.h>
2424 #include <linux/mtd/physmap.h>
25
+#include <linux/nvmem-provider.h>
2526 #include <linux/phy.h>
2627 #include <linux/clk.h>
2728 #include <linux/videodev2.h>
2829 #include <linux/v4l2-dv-timings.h>
2930 #include <linux/export.h>
3031 #include <linux/leds.h>
32
+#include <linux/regulator/fixed.h>
33
+#include <linux/regulator/machine.h>
3134
3235 #include <media/i2c/tvp514x.h>
3336
....@@ -35,9 +38,10 @@
3538 #include <asm/mach/arch.h>
3639
3740 #include <mach/common.h>
38
-#include <linux/platform_data/i2c-davinci.h>
39
-#include <mach/serial.h>
4041 #include <mach/mux.h>
42
+#include <mach/serial.h>
43
+
44
+#include <linux/platform_data/i2c-davinci.h>
4145 #include <linux/platform_data/mtd-davinci.h>
4246 #include <linux/platform_data/mmc-davinci.h>
4347 #include <linux/platform_data/usb-davinci.h>
....@@ -45,6 +49,7 @@
4549 #include <linux/platform_data/ti-aemif.h>
4650
4751 #include "davinci.h"
52
+#include "irqs.h"
4853
4954 #define DM644X_EVM_PHY_ID "davinci_mdio-0:01"
5055 #define LXT971_PHY_ID (0x001378e2)
....@@ -157,7 +162,7 @@
157162 .core_chipsel = 0,
158163 .parts = davinci_evm_nandflash_partition,
159164 .nr_parts = ARRAY_SIZE(davinci_evm_nandflash_partition),
160
- .ecc_mode = NAND_ECC_HW,
165
+ .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
161166 .ecc_bits = 1,
162167 .bbt_options = NAND_BBT_USE_FLASH,
163168 .timing = &davinci_evm_nandflash_timing,
....@@ -510,12 +515,30 @@
510515 * - ... newer boards may have more
511516 */
512517
513
-static struct at24_platform_data eeprom_info = {
514
- .byte_len = (256*1024) / 8,
515
- .page_size = 64,
516
- .flags = AT24_FLAG_ADDR16,
517
- .setup = davinci_get_mac_addr,
518
- .context = (void *)0x7f00,
518
+static struct nvmem_cell_info dm644evm_nvmem_cells[] = {
519
+ {
520
+ .name = "macaddr",
521
+ .offset = 0x7f00,
522
+ .bytes = ETH_ALEN,
523
+ }
524
+};
525
+
526
+static struct nvmem_cell_table dm644evm_nvmem_cell_table = {
527
+ .nvmem_name = "1-00500",
528
+ .cells = dm644evm_nvmem_cells,
529
+ .ncells = ARRAY_SIZE(dm644evm_nvmem_cells),
530
+};
531
+
532
+static struct nvmem_cell_lookup dm644evm_nvmem_cell_lookup = {
533
+ .nvmem_name = "1-00500",
534
+ .cell_name = "macaddr",
535
+ .dev_id = "davinci_emac.1",
536
+ .con_id = "mac-address",
537
+};
538
+
539
+static const struct property_entry eeprom_properties[] = {
540
+ PROPERTY_ENTRY_U32("pagesize", 64),
541
+ { }
519542 };
520543
521544 /*
....@@ -525,8 +548,7 @@
525548 */
526549 static struct i2c_client *dm6446evm_msp;
527550
528
-static int dm6446evm_msp_probe(struct i2c_client *client,
529
- const struct i2c_device_id *id)
551
+static int dm6446evm_msp_probe(struct i2c_client *client)
530552 {
531553 dm6446evm_msp = client;
532554 return 0;
....@@ -546,7 +568,7 @@
546568 static struct i2c_driver dm6446evm_msp_driver = {
547569 .driver.name = "dm6446evm_msp",
548570 .id_table = dm6446evm_msp_ids,
549
- .probe = dm6446evm_msp_probe,
571
+ .probe_new = dm6446evm_msp_probe,
550572 .remove = dm6446evm_msp_remove,
551573 };
552574
....@@ -625,7 +647,7 @@
625647 },
626648 {
627649 I2C_BOARD_INFO("24c256", 0x50),
628
- .platform_data = &eeprom_info,
650
+ .properties = eeprom_properties,
629651 },
630652 {
631653 I2C_BOARD_INFO("tlv320aic33", 0x1b),
....@@ -638,10 +660,11 @@
638660 static struct gpiod_lookup_table i2c_recovery_gpiod_table = {
639661 .dev_id = "i2c_davinci.1",
640662 .table = {
641
- GPIO_LOOKUP("davinci_gpio.0", DM644X_I2C_SDA_PIN, "sda",
663
+ GPIO_LOOKUP("davinci_gpio", DM644X_I2C_SDA_PIN, "sda",
642664 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
643
- GPIO_LOOKUP("davinci_gpio.0", DM644X_I2C_SCL_PIN, "scl",
665
+ GPIO_LOOKUP("davinci_gpio", DM644X_I2C_SCL_PIN, "scl",
644666 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
667
+ { }
645668 },
646669 };
647670
....@@ -662,6 +685,19 @@
662685 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
663686 }
664687 #endif
688
+
689
+/* Fixed regulator support */
690
+static struct regulator_consumer_supply fixed_supplies_3_3v[] = {
691
+ /* Baseboard 3.3V: 5V -> TPS54310PWP -> 3.3V */
692
+ REGULATOR_SUPPLY("AVDD", "1-001b"),
693
+ REGULATOR_SUPPLY("DRVDD", "1-001b"),
694
+};
695
+
696
+static struct regulator_consumer_supply fixed_supplies_1_8v[] = {
697
+ /* Baseboard 1.8V: 5V -> TPS54310PWP -> 1.8V */
698
+ REGULATOR_SUPPLY("IOVDD", "1-001b"),
699
+ REGULATOR_SUPPLY("DVDD", "1-001b"),
700
+};
665701
666702 #define VENC_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
667703
....@@ -801,6 +837,17 @@
801837
802838 #define HAS_NAND IS_ENABLED(CONFIG_MTD_NAND_DAVINCI)
803839
840
+#define GPIO_nVBUS_DRV 160
841
+
842
+static struct gpiod_lookup_table dm644evm_usb_gpio_table = {
843
+ .dev_id = "musb-davinci",
844
+ .table = {
845
+ GPIO_LOOKUP("davinci_gpio", GPIO_nVBUS_DRV, NULL,
846
+ GPIO_ACTIVE_HIGH),
847
+ { }
848
+ },
849
+};
850
+
804851 static __init void davinci_evm_init(void)
805852 {
806853 int ret;
....@@ -808,6 +855,11 @@
808855 struct davinci_soc_info *soc_info = &davinci_soc_info;
809856
810857 dm644x_register_clocks();
858
+
859
+ regulator_register_always_on(0, "fixed-dummy", fixed_supplies_1_8v,
860
+ ARRAY_SIZE(fixed_supplies_1_8v), 1800000);
861
+ regulator_register_always_on(1, "fixed-dummy", fixed_supplies_3_3v,
862
+ ARRAY_SIZE(fixed_supplies_3_3v), 3300000);
811863
812864 dm644x_init_devices();
813865
....@@ -842,6 +894,8 @@
842894 platform_add_devices(davinci_evm_devices,
843895 ARRAY_SIZE(davinci_evm_devices));
844896 #ifdef CONFIG_I2C
897
+ nvmem_add_cell_table(&dm644evm_nvmem_cell_table);
898
+ nvmem_add_cell_lookups(&dm644evm_nvmem_cell_lookup, 1);
845899 evm_init_i2c();
846900 davinci_setup_mmc(0, &dm6446evm_mmc_config);
847901 #endif
....@@ -851,6 +905,7 @@
851905 dm644x_init_asp();
852906
853907 /* irlml6401 switches over 1A, in under 8 msec */
908
+ gpiod_add_lookup_table(&dm644evm_usb_gpio_table);
854909 davinci_setup_usb(1000, 8);
855910
856911 if (IS_BUILTIN(CONFIG_PHYLIB)) {
....@@ -865,7 +920,7 @@
865920 /* Maintainer: MontaVista Software <source@mvista.com> */
866921 .atag_offset = 0x100,
867922 .map_io = davinci_evm_map_io,
868
- .init_irq = davinci_irq_init,
923
+ .init_irq = dm644x_init_irq,
869924 .init_time = dm644x_init_time,
870925 .init_machine = davinci_evm_init,
871926 .init_late = davinci_init_late,