forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/mach-davinci/board-da830-evm.c
....@@ -18,7 +18,7 @@
1818 #include <linux/platform_device.h>
1919 #include <linux/i2c.h>
2020 #include <linux/platform_data/pcf857x.h>
21
-#include <linux/platform_data/at24.h>
21
+#include <linux/property.h>
2222 #include <linux/mtd/mtd.h>
2323 #include <linux/mtd/partitions.h>
2424 #include <linux/spi/spi.h>
....@@ -29,15 +29,18 @@
2929 #include <linux/platform_data/spi-davinci.h>
3030 #include <linux/platform_data/usb-davinci.h>
3131 #include <linux/platform_data/ti-aemif.h>
32
+#include <linux/regulator/fixed.h>
3233 #include <linux/regulator/machine.h>
34
+#include <linux/nvmem-provider.h>
3335
3436 #include <asm/mach-types.h>
3537 #include <asm/mach/arch.h>
3638
3739 #include <mach/common.h>
38
-#include "cp_intc.h"
3940 #include <mach/mux.h>
4041 #include <mach/da8xx.h>
42
+
43
+#include "irqs.h"
4144
4245 #define DA830_EVM_PHY_ID ""
4346 /*
....@@ -51,61 +54,57 @@
5154 -1
5255 };
5356
54
-static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
57
+static struct regulator_consumer_supply da830_evm_usb_supplies[] = {
58
+ REGULATOR_SUPPLY("vbus", NULL),
59
+};
5560
56
-static int da830_evm_usb_set_power(unsigned port, int on)
57
-{
58
- gpio_set_value(ON_BD_USB_DRV, on);
59
- return 0;
60
-}
61
+static struct regulator_init_data da830_evm_usb_vbus_data = {
62
+ .consumer_supplies = da830_evm_usb_supplies,
63
+ .num_consumer_supplies = ARRAY_SIZE(da830_evm_usb_supplies),
64
+ .constraints = {
65
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS,
66
+ },
67
+};
6168
62
-static int da830_evm_usb_get_power(unsigned port)
63
-{
64
- return gpio_get_value(ON_BD_USB_DRV);
65
-}
69
+static struct fixed_voltage_config da830_evm_usb_vbus = {
70
+ .supply_name = "vbus",
71
+ .microvolts = 33000000,
72
+ .init_data = &da830_evm_usb_vbus_data,
73
+};
6674
67
-static int da830_evm_usb_get_oci(unsigned port)
68
-{
69
- return !gpio_get_value(ON_BD_USB_OVC);
70
-}
75
+static struct platform_device da830_evm_usb_vbus_device = {
76
+ .name = "reg-fixed-voltage",
77
+ .id = 0,
78
+ .dev = {
79
+ .platform_data = &da830_evm_usb_vbus,
80
+ },
81
+};
7182
72
-static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
83
+static struct gpiod_lookup_table da830_evm_usb_oc_gpio_lookup = {
84
+ .dev_id = "ohci-da8xx",
85
+ .table = {
86
+ GPIO_LOOKUP("davinci_gpio", ON_BD_USB_OVC, "oc", 0),
87
+ { }
88
+ },
89
+};
7390
74
-static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
75
-{
76
- int irq = gpio_to_irq(ON_BD_USB_OVC);
77
- int error = 0;
91
+static struct gpiod_lookup_table da830_evm_usb_vbus_gpio_lookup = {
92
+ .dev_id = "reg-fixed-voltage.0",
93
+ .table = {
94
+ GPIO_LOOKUP("davinci_gpio", ON_BD_USB_DRV, NULL, 0),
95
+ { }
96
+ },
97
+};
7898
79
- if (handler != NULL) {
80
- da830_evm_usb_ocic_handler = handler;
81
-
82
- error = request_irq(irq, da830_evm_usb_ocic_irq,
83
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
84
- "OHCI over-current indicator", NULL);
85
- if (error)
86
- pr_err("%s: could not request IRQ to watch over-current indicator changes\n",
87
- __func__);
88
- } else
89
- free_irq(irq, NULL);
90
-
91
- return error;
92
-}
99
+static struct gpiod_lookup_table *da830_evm_usb_gpio_lookups[] = {
100
+ &da830_evm_usb_oc_gpio_lookup,
101
+ &da830_evm_usb_vbus_gpio_lookup,
102
+};
93103
94104 static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
95
- .set_power = da830_evm_usb_set_power,
96
- .get_power = da830_evm_usb_get_power,
97
- .get_oci = da830_evm_usb_get_oci,
98
- .ocic_notify = da830_evm_usb_ocic_notify,
99
-
100105 /* TPS2065 switch @ 5V */
101106 .potpgt = (3 + 1) / 2, /* 3 ms max */
102107 };
103
-
104
-static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
105
-{
106
- da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1);
107
- return IRQ_HANDLED;
108
-}
109108
110109 static __init void da830_evm_usb_init(void)
111110 {
....@@ -115,6 +114,9 @@
115114 if (ret)
116115 pr_warn("%s: USB PHY CLK registration failed: %d\n",
117116 __func__, ret);
117
+
118
+ gpiod_add_lookup_tables(da830_evm_usb_gpio_lookups,
119
+ ARRAY_SIZE(da830_evm_usb_gpio_lookups));
118120
119121 ret = da8xx_register_usb_phy();
120122 if (ret)
....@@ -141,21 +143,11 @@
141143 return;
142144 }
143145
144
- ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV");
146
+ ret = platform_device_register(&da830_evm_usb_vbus_device);
145147 if (ret) {
146
- pr_err("%s: failed to request GPIO for USB 1.1 port power control: %d\n",
147
- __func__, ret);
148
+ pr_warn("%s: Unable to register the vbus supply\n", __func__);
148149 return;
149150 }
150
- gpio_direction_output(ON_BD_USB_DRV, 0);
151
-
152
- ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC");
153
- if (ret) {
154
- pr_err("%s: failed to request GPIO for USB 1.1 port over-current indicator: %d\n",
155
- __func__, ret);
156
- return;
157
- }
158
- gpio_direction_input(ON_BD_USB_OVC);
159151
160152 ret = da8xx_register_usb11(&da830_evm_usb11_pdata);
161153 if (ret)
....@@ -207,10 +199,11 @@
207199 .dev_id = "da830-mmc.0",
208200 .table = {
209201 /* gpio chip 1 contains gpio range 32-63 */
210
- GPIO_LOOKUP("davinci_gpio.0", DA830_MMCSD_CD_PIN, "cd",
202
+ GPIO_LOOKUP("davinci_gpio", DA830_MMCSD_CD_PIN, "cd",
211203 GPIO_ACTIVE_LOW),
212
- GPIO_LOOKUP("davinci_gpio.0", DA830_MMCSD_WP_PIN, "wp",
204
+ GPIO_LOOKUP("davinci_gpio", DA830_MMCSD_WP_PIN, "wp",
213205 GPIO_ACTIVE_LOW),
206
+ { }
214207 },
215208 };
216209
....@@ -273,7 +266,7 @@
273266 }
274267 };
275268
276
-/* flash bbt decriptors */
269
+/* flash bbt descriptors */
277270 static uint8_t da830_evm_nand_bbt_pattern[] = { 'B', 'b', 't', '0' };
278271 static uint8_t da830_evm_nand_mirror_pattern[] = { '1', 't', 'b', 'B' };
279272
....@@ -313,7 +306,7 @@
313306 .core_chipsel = 1,
314307 .parts = da830_evm_nand_partitions,
315308 .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions),
316
- .ecc_mode = NAND_ECC_HW,
309
+ .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
317310 .ecc_bits = 4,
318311 .bbt_options = NAND_BBT_USE_FLASH,
319312 .bbt_td = &da830_evm_nand_bbt_main_descr,
....@@ -435,12 +428,30 @@
435428 static inline void da830_evm_init_lcdc(int mux_mode) { }
436429 #endif
437430
438
-static struct at24_platform_data da830_evm_i2c_eeprom_info = {
439
- .byte_len = SZ_256K / 8,
440
- .page_size = 64,
441
- .flags = AT24_FLAG_ADDR16,
442
- .setup = davinci_get_mac_addr,
443
- .context = (void *)0x7f00,
431
+static struct nvmem_cell_info da830_evm_nvmem_cells[] = {
432
+ {
433
+ .name = "macaddr",
434
+ .offset = 0x7f00,
435
+ .bytes = ETH_ALEN,
436
+ }
437
+};
438
+
439
+static struct nvmem_cell_table da830_evm_nvmem_cell_table = {
440
+ .nvmem_name = "1-00500",
441
+ .cells = da830_evm_nvmem_cells,
442
+ .ncells = ARRAY_SIZE(da830_evm_nvmem_cells),
443
+};
444
+
445
+static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = {
446
+ .nvmem_name = "1-00500",
447
+ .cell_name = "macaddr",
448
+ .dev_id = "davinci_emac.1",
449
+ .con_id = "mac-address",
450
+};
451
+
452
+static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
453
+ PROPERTY_ENTRY_U32("pagesize", 64),
454
+ { }
444455 };
445456
446457 static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
....@@ -474,7 +485,7 @@
474485 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
475486 {
476487 I2C_BOARD_INFO("24c256", 0x50),
477
- .platform_data = &da830_evm_i2c_eeprom_info,
488
+ .properties = da830_evm_i2c_eeprom_properties,
478489 },
479490 {
480491 I2C_BOARD_INFO("tlv320aic3x", 0x18),
....@@ -620,6 +631,10 @@
620631 __func__, ret);
621632
622633 davinci_serial_init(da8xx_serial_device);
634
+
635
+ nvmem_add_cell_table(&da830_evm_nvmem_cell_table);
636
+ nvmem_add_cell_lookups(&da830_evm_nvmem_cell_lookup, 1);
637
+
623638 i2c_register_board_info(1, da830_evm_i2c_devices,
624639 ARRAY_SIZE(da830_evm_i2c_devices));
625640
....@@ -667,7 +682,7 @@
667682 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
668683 .atag_offset = 0x100,
669684 .map_io = da830_evm_map_io,
670
- .init_irq = cp_intc_init,
685
+ .init_irq = da830_init_irq,
671686 .init_time = da830_init_time,
672687 .init_machine = da830_evm_init,
673688 .init_late = davinci_init_late,