1 #include <generated/autoconf.h>
2 #include <linux/device.h>
3 #include <linux/dma-mapping.h>
4 #include <linux/ioport.h>
6 #include <linux/delay.h>
7 #include <linux/platform_device.h>
8 #include <linux/android_pmem.h>
9 #include <linux/memblock.h>
10 #include <asm/setup.h>
11 #include <asm/mach/arch.h>
12 #include <linux/sysfs.h>
14 #include <linux/spi/spi.h>
15 #include <linux/amba/bus.h>
16 #include <linux/amba/clcd.h>
17 #include <linux/musb/musb.h>
18 #include <linux/musbfsh.h>
19 #include "mach/memory.h"
20 #include "mach/irqs.h"
21 #include <mach/mt_reg_base.h>
22 #include <mach/devs.h>
23 #include <mach/mt_boot.h>
24 #include <linux/version.h>
25 #include <mach/mtk_ccci_helper.h>
26 #include <mach/mtk_eemcs_helper.h>
27 #include <mach/mtk_memcfg.h>
28 #include <mach/dfo_boot.h>
29 #include <mach/dfo_boot_default.h>
30 #include <linux/aee.h>
31 #include <linux/mrdump.h>
32 #ifdef CONFIG_MTK_MTD_NAND
33 #include <mach/nand_device_define.h>
34 #include <mach/mt_partitioninfo.h>
36 #define SERIALNO_LEN 32
37 static char serial_number
[SERIALNO_LEN
];
39 extern BOOTMODE
get_boot_mode(void);
40 extern u32
get_devinfo_with_index(u32 index
);
41 extern u32 g_devinfo_data
[];
42 extern u32 g_devinfo_data_size
;
43 extern void adjust_kernel_cmd_line_setting_for_console(char*, char*);
44 unsigned int mtk_get_max_DRAM_size(void);
45 resource_size_t
get_actual_DRAM_size(void);
47 #ifdef CONFIG_MTK_MTD_NAND
48 struct tag_pt_info otp_info
;
49 struct tag_pt_info bmt_info
;
50 unsigned int flash_number
;
51 flashdev_info_t
*gen_FlashTable_ptr
;
52 flashdev_info_t gen_FlashTable_p
[MAX_FLASH
];
60 static int use_bl_fb
= 0;
62 /*=======================================================================*/
63 /* MT8127 USB GADGET */
64 /*=======================================================================*/
65 static u64 usb_dmamask
= DMA_BIT_MASK(32);
66 static struct musb_hdrc_config musb_config_mt65xx
= {
75 static struct musb_hdrc_platform_data usb_data
= {
76 #ifdef CONFIG_USB_MTK_OTG
79 .mode
= MUSB_PERIPHERAL
,
81 .config
= &musb_config_mt65xx
,
83 struct platform_device mt_device_usb
= {
85 .id
= -1, //only one such device
87 .platform_data
= &usb_data
,
88 .dma_mask
= &usb_dmamask
,
89 .coherent_dma_mask
= DMA_BIT_MASK(32),
90 /*.release=musbfsh_hcd_release,*/
94 /*=======================================================================*/
95 /* MT6589 USB11 Host */
96 /*=======================================================================*/
97 #if defined(CONFIG_MTK_USBFSH)
98 static u64 usb11_dmamask
= DMA_BIT_MASK(32);
99 extern void musbfsh_hcd_release (struct device
*dev
);
101 static struct musbfsh_hdrc_config musbfsh_config_mt65xx
= {
109 static struct musbfsh_hdrc_platform_data usb_data_mt65xx
= {
111 .config
= &musbfsh_config_mt65xx
,
113 static struct platform_device mt_usb11_dev
= {
117 .platform_data
= &usb_data_mt65xx
,
118 .dma_mask
= &usb11_dmamask
,
119 .coherent_dma_mask
= DMA_BIT_MASK(32),
120 .release
= musbfsh_hcd_release
,
125 /*=======================================================================*/
126 /* MT6589 UART Ports */
127 /*=======================================================================*/
128 #if defined(CFG_DEV_UART1)
129 static struct resource mtk_resource_uart1
[] = {
131 .start
= IO_VIRT_TO_PHYS(UART1_BASE
),
132 .end
= IO_VIRT_TO_PHYS(UART1_BASE
) + MTK_UART_SIZE
- 1,
133 .flags
= IORESOURCE_MEM
,
136 .start
= MT_UART1_IRQ_ID
,
137 .flags
= IORESOURCE_IRQ
,
142 #if defined(CFG_DEV_UART2)
143 static struct resource mtk_resource_uart2
[] = {
145 .start
= IO_VIRT_TO_PHYS(UART2_BASE
),
146 .end
= IO_VIRT_TO_PHYS(UART2_BASE
) + MTK_UART_SIZE
- 1,
147 .flags
= IORESOURCE_MEM
,
150 .start
= MT_UART2_IRQ_ID
,
151 .flags
= IORESOURCE_IRQ
,
156 #if defined(CFG_DEV_UART3)
157 static struct resource mtk_resource_uart3
[] = {
159 .start
= IO_VIRT_TO_PHYS(UART3_BASE
),
160 .end
= IO_VIRT_TO_PHYS(UART3_BASE
) + MTK_UART_SIZE
- 1,
161 .flags
= IORESOURCE_MEM
,
164 .start
= MT_UART3_IRQ_ID
,
165 .flags
= IORESOURCE_IRQ
,
170 #if defined(CFG_DEV_UART4)
171 static struct resource mtk_resource_uart4
[] = {
173 .start
= IO_VIRT_TO_PHYS(UART4_BASE
),
174 .end
= IO_VIRT_TO_PHYS(UART4_BASE
) + MTK_UART_SIZE
- 1,
175 .flags
= IORESOURCE_MEM
,
178 .start
= MT_UART4_IRQ_ID
,
179 .flags
= IORESOURCE_IRQ
,
184 static struct platform_device mtk_device_btif
= {
189 extern unsigned long max_pfn
;
190 #define RESERVED_MEM_MODEM (0x0) // do not reserve memory in advance, do it in mt_fixup
191 #ifndef CONFIG_RESERVED_MEM_SIZE_FOR_PMEM
192 #define CONFIG_RESERVED_MEM_SIZE_FOR_PMEM 1
196 #if defined(CONFIG_MTK_FB)
197 char temp_command_line
[1024] = {0};
198 extern unsigned int DISP_GetVRamSizeBoot(char* cmdline
);
199 #define RESERVED_MEM_SIZE_FOR_FB (DISP_GetVRamSizeBoot((char*)&temp_command_line))
200 extern void mtkfb_set_lcm_inited(bool isLcmInited
);
202 #define RESERVED_MEM_SIZE_FOR_FB (0x400000)
206 * The memory size reserved for PMEM
208 * The size could be varied in different solutions.
209 * The size is set in mt65xx_fixup function.
210 * - MT8127 in develop should be 0x3600000
211 * - MT8127 SQC should be 0x0
213 resource_size_t RESERVED_MEM_SIZE_FOR_PMEM
= 0x1700000;
214 phys_addr_t pmem_start
= 0x12345678; // pmem_start is inited in mt_fixup
215 resource_size_t kernel_mem_sz
= 0x0; // kernel_mem_sz is inited in mt_fixup
216 resource_size_t RESERVED_MEM_SIZE_FOR_TEST_3D
= 0x0;
217 resource_size_t FB_SIZE_EXTERN
= 0x0;
218 resource_size_t RESERVED_MEM_SIZE_FOR_FB_MAX
= 0x1500000;
220 #define TOTAL_RESERVED_MEM_SIZE (RESERVED_MEM_SIZE_FOR_PMEM + \
221 RESERVED_MEM_SIZE_FOR_FB)
223 #define MAX_PFN ((max_pfn << PAGE_SHIFT) + PHYS_OFFSET)
225 #define PMEM_MM_START (pmem_start)
226 #define PMEM_MM_SIZE (RESERVED_MEM_SIZE_FOR_PMEM)
228 #define TEST_3D_START (PMEM_MM_START + PMEM_MM_SIZE)
229 #define TEST_3D_SIZE (RESERVED_MEM_SIZE_FOR_TEST_3D)
231 #define FB_START (TEST_3D_START + RESERVED_MEM_SIZE_FOR_TEST_3D)
232 #define FB_SIZE (RESERVED_MEM_SIZE_FOR_FB)
234 static struct platform_device mtk_device_uart
[] = {
236 #if defined(CFG_DEV_UART1)
240 .num_resources
= ARRAY_SIZE(mtk_resource_uart1
),
241 .resource
= mtk_resource_uart1
,
244 #if defined(CFG_DEV_UART2)
248 .num_resources
= ARRAY_SIZE(mtk_resource_uart2
),
249 .resource
= mtk_resource_uart2
,
252 #if defined(CFG_DEV_UART3)
256 .num_resources
= ARRAY_SIZE(mtk_resource_uart3
),
257 .resource
= mtk_resource_uart3
,
261 #if defined(CFG_DEV_UART4)
265 .num_resources
= ARRAY_SIZE(mtk_resource_uart4
),
266 .resource
= mtk_resource_uart4
,
270 //FIX-ME: marked for early porting
271 #if defined(CONFIG_FIQ_DEBUGGER)
272 extern void fiq_uart_fixup(int uart_port
);
273 extern struct platform_device mt_fiq_debugger
;
276 /* ========================================================================= */
277 /* implementation of serial number attribute */
278 /* ========================================================================= */
279 #define to_sysinfo_attribute(x) container_of(x, struct sysinfo_attribute, attr)
281 struct sysinfo_attribute
{
282 struct attribute attr
;
283 ssize_t (*show
)(char *buf
);
284 ssize_t (*store
)(const char *buf
, size_t count
);
287 static struct kobject sn_kobj
;
289 static ssize_t
sn_show(char *buf
){
290 return snprintf(buf
, 4096, "%s\n", serial_number
);
292 //[FEATURE]-Add-BEGIN by SCDTABLET.(meiqin),04/14/2015,modify SN
293 static ssize_t
sn_store(char *buf
, size_t count
){
294 memset(serial_number
, 0,sizeof(serial_number
));
295 memcpy(serial_number
,buf
,count
);
298 //[FEATURE]-Add-END by SCDTABLET.(meiqin)
301 struct sysinfo_attribute sn_attr
= {
302 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
303 .attr
= {"serial_number", THIS_MODULE
, 0644},
305 .attr
= {"serial_number", 0644},
308 //[FEATURE]-Mod-BEGIN by SCDTABLET.(meiqin),04/14/2015,modify SN
310 //[FEATURE]-Mod-END by SCDTABLET.(meiqin)
313 static ssize_t
sysinfo_show(struct kobject
*kobj
, struct attribute
*attr
, char *buf
)
315 struct sysinfo_attribute
*sysinfo_attr
= to_sysinfo_attribute(attr
);
318 if(sysinfo_attr
->show
)
319 ret
= sysinfo_attr
->show(buf
);
324 static ssize_t
sysinfo_store(struct kobject
*kobj
, struct attribute
*attr
, const char *buf
, size_t count
)
326 struct sysinfo_attribute
*sysinfo_attr
= to_sysinfo_attribute(attr
);
329 if(sysinfo_attr
->store
)
330 ret
= sysinfo_attr
->store(buf
, count
);
335 static struct sysfs_ops sn_sysfs_ops
= {
336 .show
= sysinfo_show
,
337 .store
= sysinfo_store
340 static struct attribute
*sn_attrs
[] = {
345 static struct kobj_type sn_ktype
= {
346 .sysfs_ops
= &sn_sysfs_ops
,
347 .default_attrs
= sn_attrs
350 #define HASH_ARRAY_SIZE 4
352 static char udc_chr
[32] = {"ABCDEFGHIJKLMNOPQRSTUVWSYZ456789"};
353 int get_serial(uint64_t hwkey
, uint32_t chipid
, char ser
[SERIALNO_LEN
])
355 uint16_t hashkey
[HASH_ARRAY_SIZE
];
358 uint64_t tmp
= hwkey
;
360 memset(ser
, 0x00, SERIALNO_LEN
);
362 /* split to 4 key with 16-bit width each */
364 for (idx
= 0; idx
< HASH_ARRAY_SIZE
; idx
++) {
365 hashkey
[idx
] = (uint16_t)(tmp
& 0xffff);
369 /* hash the key with chip id */
371 for (idx
= 0; idx
< HASH_ARRAY_SIZE
; idx
++) {
373 hashkey
[idx
] = (hashkey
[idx
] >> digit
) | (hashkey
[idx
] << (16-digit
));
377 /* generate serail using hashkey */
379 for (idx
= 0; idx
< HASH_ARRAY_SIZE
; idx
++) {
380 ser
[ser_idx
++] = (hashkey
[idx
] & 0x001f);
381 ser
[ser_idx
++] = (hashkey
[idx
] & 0x00f8) >> 3;
382 ser
[ser_idx
++] = (hashkey
[idx
] & 0x1f00) >> 8;
383 ser
[ser_idx
++] = (hashkey
[idx
] & 0xf800) >> 11;
385 for (idx
= 0; idx
< ser_idx
; idx
++)
386 ser
[idx
] = udc_chr
[(int)ser
[idx
]];
391 /*=======================================================================*/
393 /*=======================================================================*/
394 struct platform_device gpio_dev
=
399 struct platform_device fh_dev
=
401 .name
= "mt-freqhopping",
405 #if defined(CONFIG_SERIAL_AMBA_PL011)
406 static struct amba_device uart1_device
=
410 .coherent_dma_mask
= ~0,
411 .init_name
= "dev:f1",
412 .platform_data
= NULL
,
417 .end
= 0xE01F1000 + SZ_4K
- 1,
418 .flags
= IORESOURCE_MEM
,
421 .irq
= MT_UART1_IRQ_ID
,
425 /*=======================================================================*/
426 /* MT8127 MSDC Hosts */
427 /*=======================================================================*/
428 #if defined(CFG_DEV_MSDC0)
429 static struct resource mt_resource_msdc0
[] = {
431 .start
= IO_VIRT_TO_PHYS(MSDC_0_BASE
),
432 .end
= IO_VIRT_TO_PHYS(MSDC_0_BASE
) + 0x108,
433 .flags
= IORESOURCE_MEM
,
436 .start
= MT_MSDC0_IRQ_ID
,
437 .flags
= IORESOURCE_IRQ
,
442 #if defined(CFG_DEV_MSDC1)
443 static struct resource mt_resource_msdc1
[] = {
445 .start
= IO_VIRT_TO_PHYS(MSDC_1_BASE
),
446 .end
= IO_VIRT_TO_PHYS(MSDC_1_BASE
) + 0x108,
447 .flags
= IORESOURCE_MEM
,
450 .start
= MT_MSDC1_IRQ_ID
,
451 .flags
= IORESOURCE_IRQ
,
456 #if defined(CFG_DEV_MSDC2)
457 static struct resource mt_resource_msdc2
[] = {
459 .start
= IO_VIRT_TO_PHYS(MSDC_2_BASE
),
460 .end
= IO_VIRT_TO_PHYS(MSDC_2_BASE
) + 0x108,
461 .flags
= IORESOURCE_MEM
,
464 .start
= MT_MSDC2_IRQ_ID
,
465 //.start = MSDC2_IRQ_ID,
466 .flags
= IORESOURCE_IRQ
,
471 #if defined(CFG_DEV_MSDC3)
472 static struct resource mt_resource_msdc3
[] = {
474 .start
= IO_VIRT_TO_PHYS(MSDC_3_BASE
),
475 .end
= IO_VIRT_TO_PHYS(MSDC_3_BASE
) + 0x108,
476 .flags
= IORESOURCE_MEM
,
479 .start
= MT_MSDC3_IRQ_ID
,
480 .flags
= IORESOURCE_IRQ
,
484 #if defined(CFG_DEV_MSDC4)
485 static struct resource mt_resource_msdc4
[] = {
487 .start
= IO_VIRT_TO_PHYS(MSDC_4_BASE
),
488 .end
= IO_VIRT_TO_PHYS(MSDC_4_BASE
) + 0x108,
489 .flags
= IORESOURCE_MEM
,
492 .start
= MT_MSDC4_IRQ_ID
,
493 .flags
= IORESOURCE_IRQ
,
498 #if defined(CONFIG_MTK_FB)
499 static u64 mtkfb_dmamask
= ~(u32
)0;
501 static struct resource resource_fb
[] = {
503 .start
= 0, /* Will be redefined later */
505 .flags
= IORESOURCE_MEM
509 static struct platform_device mt6575_device_fb
= {
512 .num_resources
= ARRAY_SIZE(resource_fb
),
513 .resource
= resource_fb
,
515 .dma_mask
= &mtkfb_dmamask
,
516 .coherent_dma_mask
= 0xffffffff,
521 #ifdef MTK_MULTIBRIDGE_SUPPORT
522 static struct platform_device mtk_multibridge_dev
= {
523 .name
= "multibridge",
527 #ifdef CONFIG_MTK_HDMI_SUPPORT
528 static struct platform_device mtk_hdmi_dev
= {
535 #ifdef MTK_MT8193_SUPPORT
536 static struct platform_device mtk_ckgen_dev
= {
537 .name
= "mt8193-ckgen",
543 #if defined (CONFIG_MTK_SPI)
544 static struct resource mt_spi_resources
[] =
547 .start
= IO_VIRT_TO_PHYS(SPI1_BASE
),
548 .end
= IO_VIRT_TO_PHYS(SPI1_BASE
) + 0x0028,
549 .flags
= IORESOURCE_MEM
,
552 .start
= MT6582_SPI1_IRQ_ID
,
553 .flags
= IORESOURCE_IRQ
,
557 static struct platform_device mt_spi_device
= {
559 .num_resources
= ARRAY_SIZE(mt_spi_resources
),
560 .resource
=mt_spi_resources
566 #if defined(CONFIG_USB_MTK_ACM_TEMP)
567 struct platform_device usbacm_temp_device
= {
568 .name
="USB_ACM_Temp_Driver",
573 #if defined(CONFIG_MTK_ACCDET)
574 struct platform_device accdet_device
= {
575 .name
="Accdet_Driver",
578 //.release = accdet_dumy_release,
583 #if defined(MTK_TVOUT_SUPPORT)
585 static struct resource mt6575_TVOUT_resource
[] = {
588 .end
= TVC_BASE
+ 0x78,
589 .flags
= IORESOURCE_MEM
,
592 .start
= TV_ROT_BASE
,
593 .end
= TV_ROT_BASE
+ 0x378,
594 .flags
= IORESOURCE_MEM
,
598 .end
= TVE_BASE
+ 0x84,
599 .flags
= IORESOURCE_MEM
,
603 static u64 mt6575_TVOUT_dmamask
= ~(u32
)0;
605 static struct platform_device mt6575_TVOUT_dev
= {
608 .num_resources
= ARRAY_SIZE(mt6575_TVOUT_resource
),
609 .resource
= mt6575_TVOUT_resource
,
611 .dma_mask
= &mt6575_TVOUT_dmamask
,
612 .coherent_dma_mask
= 0xffffffffUL
616 static struct platform_device mt_device_msdc
[] =
618 #if defined(CFG_DEV_MSDC0)
622 .num_resources
= ARRAY_SIZE(mt_resource_msdc0
),
623 .resource
= mt_resource_msdc0
,
625 .platform_data
= &msdc0_hw
,
629 #if defined(CFG_DEV_MSDC1)
633 .num_resources
= ARRAY_SIZE(mt_resource_msdc1
),
634 .resource
= mt_resource_msdc1
,
636 .platform_data
= &msdc1_hw
,
640 #if defined(CFG_DEV_MSDC2)
644 .num_resources
= ARRAY_SIZE(mt_resource_msdc2
),
645 .resource
= mt_resource_msdc2
,
647 .platform_data
= &msdc2_hw
,
651 #if defined(CFG_DEV_MSDC3)
655 .num_resources
= ARRAY_SIZE(mt_resource_msdc3
),
656 .resource
= mt_resource_msdc3
,
658 .platform_data
= &msdc3_hw
,
662 #if defined(CFG_DEV_MSDC4)
666 .num_resources
= ARRAY_SIZE(mt_resource_msdc4
),
667 .resource
= mt_resource_msdc4
,
669 .platform_data
= &msdc4_hw
,
676 /*=======================================================================*/
678 /*=======================================================================*/
679 #ifdef CONFIG_MTK_KEYPAD
680 static struct platform_device kpd_pdev
= {
687 /*=======================================================================*/
688 /* MT6589 RFKill module (BT and WLAN) */
689 /*=======================================================================*/
690 /* MT66xx RFKill BT */
691 struct platform_device mt_rfkill_device
= {
697 /*=======================================================================*/
698 /* HID Keyboard add by zhangsg */
699 /*=======================================================================*/
701 #if defined(CONFIG_KEYBOARD_HID)
702 static struct platform_device mt_hid_dev
= {
703 .name
= "hid-keyboard",
708 /*=======================================================================*/
709 /* UIBC input device, add by Seraph */
710 /*=======================================================================*/
712 #if defined(CONFIG_MTK_WFD_SUPPORT)
713 static struct platform_device mt_uibc_dev
= {
719 /*=======================================================================*/
720 /* MT6575 Touch Panel */
721 /*=======================================================================*/
722 static struct platform_device mtk_tpd_dev
= {
727 /*=======================================================================*/
729 /*=======================================================================*/
730 #if defined(CUSTOM_KERNEL_OFN)
731 static struct platform_device ofn_driver
=
738 /*=======================================================================*/
740 /*=======================================================================*/
741 #ifdef CONFIG_CPU_FREQ
742 static struct platform_device cpufreq_pdev
= {
743 .name
= "mt-cpufreq",
748 /*=======================================================================*/
749 /* MT6575 Thermal Controller module */
750 /*=======================================================================*/
751 struct platform_device thermal_pdev
= {
752 .name
= "mtk-thermal",
757 struct platform_device mtk_therm_mon_pdev
= {
758 .name
= "mtk-therm-mon",
763 /*=======================================================================*/
765 /*=======================================================================*/
766 struct platform_device ptp_pdev
= {
771 /*=======================================================================*/
772 /* MT6589 SPM-MCDI module */
773 /*=======================================================================*/
774 struct platform_device spm_mcdi_pdev
= {
775 .name
= "mtk-spm-mcdi",
779 /*=======================================================================*/
780 /* MT6589 USIF-DUMCHAR */
781 /*=======================================================================*/
783 static struct platform_device dummychar_device
=
785 .name
= "dummy_char",
789 /*=======================================================================*/
791 /*=======================================================================*/
792 static struct platform_device masp_device
=
799 /*=======================================================================*/
801 /*=======================================================================*/
802 #if defined(CONFIG_MTK_MTD_NAND)
803 #define NFI_base NFI_BASE//0x80032000
804 #define NFIECC_base NFIECC_BASE//0x80038000
805 static struct resource mtk_resource_nand
[] = {
807 .start
= IO_VIRT_TO_PHYS(NFI_base
),
808 .end
= IO_VIRT_TO_PHYS(NFI_base
) + 0x1A0,
809 .flags
= IORESOURCE_MEM
,
812 .start
= IO_VIRT_TO_PHYS(NFIECC_base
),
813 .end
= IO_VIRT_TO_PHYS(NFIECC_base
) + 0x150,
814 .flags
= IORESOURCE_MEM
,
817 .start
= MT_NFI_IRQ_ID
,
818 .flags
= IORESOURCE_IRQ
,
821 .start
= MT_NFIECC_IRQ_ID
,
822 .flags
= IORESOURCE_IRQ
,
826 static struct platform_device mtk_nand_dev
= {
829 .num_resources
= ARRAY_SIZE(mtk_resource_nand
),
830 .resource
= mtk_resource_nand
,
832 .platform_data
= &mtk_nand_hw
,
837 /*=======================================================================*/
839 /*=======================================================================*/
840 #if defined(CONFIG_MTK_SOUND)
841 static u64 AudDrv_dmamask
= 0xffffffffUL
;
842 static struct platform_device AudDrv_device
= {
843 .name
= "AudDrv_driver_device",
846 .dma_mask
= &AudDrv_dmamask
,
847 .coherent_dma_mask
= 0xffffffffUL
851 static u64 AudDrv_btcvsd_dmamask
= 0xffffffffUL
;
852 static struct platform_device AudDrv_device2
= {
853 .name
= "AudioMTKBTCVSD",
856 .dma_mask
= &AudDrv_btcvsd_dmamask
,
857 .coherent_dma_mask
= 0xffffffffUL
860 #endif /* CONFIG_MTK_SOUND */
862 #if defined(CONFIG_SND_SOC_MT8127)
863 static struct platform_device mtk_soc_dl1_pcm_device
= {
864 .name
= "mt-soc-dl1-pcm",
865 .id
= PLATFORM_DEVID_NONE
,
868 static struct platform_device mtk_soc_ul1_pcm_device
= {
869 .name
= "mt-soc-ul1-pcm",
870 .id
= PLATFORM_DEVID_NONE
,
873 static struct platform_device mtk_soc_pmic_codec_device
= {
874 .name
= "mt-soc-codec",
875 .id
= PLATFORM_DEVID_NONE
,
878 static struct platform_device mtk_soc_stub_dai_device
= {
879 .name
= "mt-soc-dai-driver",
880 .id
= PLATFORM_DEVID_NONE
,
883 static struct platform_device mtk_soc_stub_codec_device
= {
884 .name
= "mt-soc-codec-stub",
885 .id
= PLATFORM_DEVID_NONE
,
888 static struct platform_device mtk_soc_btsco_pcm_device
= {
889 .name
= "mt-soc-btsco-pcm",
890 .id
= PLATFORM_DEVID_NONE
,
893 static struct platform_device mtk_soc_routing_pcm_device
= {
894 .name
= "mt-soc-routing-pcm",
895 .id
= PLATFORM_DEVID_NONE
,
898 static struct platform_device mtk_soc_hdmi_pcm_device
= {
899 .name
= "mt-soc-hdmi-pcm",
900 .id
= PLATFORM_DEVID_NONE
,
903 static struct platform_device mtk_soc_hdmi_dai_device
= {
904 .name
= "mt-audio-hdmi",
905 .id
= PLATFORM_DEVID_NONE
,
908 //static struct mt_audio_platform_data audio_platform_data;
910 static struct platform_device mtk_soc_machine_device
= {
911 .name
= "mt-soc-machine",
912 .id
= PLATFORM_DEVID_NONE
,
914 //.platform_data = &audio_platform_data,
915 .coherent_dma_mask
= DMA_BIT_MASK(32),
919 static struct platform_device
*mtk_soc_audio_devices
[] __initdata
= {
920 &mtk_soc_dl1_pcm_device
,
921 &mtk_soc_ul1_pcm_device
,
922 &mtk_soc_pmic_codec_device
,
923 &mtk_soc_stub_dai_device
,
924 &mtk_soc_stub_codec_device
,
925 &mtk_soc_btsco_pcm_device
,
926 &mtk_soc_routing_pcm_device
,
927 &mtk_soc_hdmi_pcm_device
,
928 &mtk_soc_hdmi_dai_device
,
929 &mtk_soc_machine_device
,
931 #endif /* CONFIG_SND_SOC_MT8127 */
934 /*=======================================================================*/
936 /*=======================================================================*/
937 //static struct i2c_board_info __initdata i2c_devs0[]={
938 // { I2C_BOARD_INFO("ADXL345", 0x53),},
939 // { I2C_BOARD_INFO("A320", 0x57),},
940 // { I2C_BOARD_INFO("ami304", (0x1E>>1)),},//0x1E>>1
941 // { I2C_BOARD_INFO("CM3623", (0x92>>1)),},//0x92>>1
942 // { I2C_BOARD_INFO("MPU3000", (0xD0>>1)),},//0xD0>>1
943 // { I2C_BOARD_INFO("mtk-tpd", (0xBA>>1)),},
945 //static struct i2c_board_info __initdata i2c_devs1[]={
946 // { I2C_BOARD_INFO("kd_camera_hw", 0xfe), },
947 // { I2C_BOARD_INFO("FM50AF", 0x18), },
948 // { I2C_BOARD_INFO("dummy_eeprom", 0xA0),},
949 // { I2C_BOARD_INFO("EEPROM_S24CS64A", 0xAA),},
952 //static struct i2c_board_info __initdata i2c_devs2[]={
953 //#ifndef CONFIG_MT8127_FPGA
954 // { I2C_BOARD_INFO("mt6329_pmic", 0x60), },
955 //#endif //End of CONFIG_MT8127_FPGA
956 // { I2C_BOARD_INFO("mt6329_pmic_bank1", 0x61), },
958 static struct resource mt_resource_i2c0
[] = {
960 .start
= IO_VIRT_TO_PHYS(I2C0_BASE
),
961 .end
= IO_VIRT_TO_PHYS(I2C0_BASE
) + 0x70,
962 .flags
= IORESOURCE_MEM
,
965 .start
= MT_I2C0_IRQ_ID
,
966 .flags
= IORESOURCE_IRQ
,
970 static struct resource mt_resource_i2c1
[] = {
972 .start
= IO_VIRT_TO_PHYS(I2C1_BASE
),
973 .end
= IO_VIRT_TO_PHYS(I2C1_BASE
) + 0x70,
974 .flags
= IORESOURCE_MEM
,
977 .start
= MT_I2C1_IRQ_ID
,
978 .flags
= IORESOURCE_IRQ
,
982 static struct resource mt_resource_i2c2
[] = {
984 .start
= IO_VIRT_TO_PHYS(I2C2_BASE
),
985 .end
= IO_VIRT_TO_PHYS(I2C2_BASE
) + 0x70,
986 .flags
= IORESOURCE_MEM
,
989 .start
= MT_I2C2_IRQ_ID
,
990 .flags
= IORESOURCE_IRQ
,
994 static struct platform_device mt_device_i2c
[] = {
998 .num_resources
= ARRAY_SIZE(mt_resource_i2c0
),
999 .resource
= mt_resource_i2c0
,
1004 .num_resources
= ARRAY_SIZE(mt_resource_i2c1
),
1005 .resource
= mt_resource_i2c1
,
1010 .num_resources
= ARRAY_SIZE(mt_resource_i2c2
),
1011 .resource
= mt_resource_i2c2
,
1018 static u64 mtk_smi_dmamask
= ~(u32
)0;
1020 static struct platform_device mtk_smi_dev
= {
1024 .dma_mask
= &mtk_smi_dmamask
,
1025 .coherent_dma_mask
= 0xffffffffUL
1029 static u64 mtk_m4u_dmamask
= ~(u32
)0;
1031 static struct platform_device mtk_m4u_dev
= {
1032 .name
= "M4U_device",
1035 .dma_mask
= &mtk_m4u_dmamask
,
1036 .coherent_dma_mask
= 0xffffffffUL
1041 /*=======================================================================*/
1042 /* MT6573 GPS module */
1043 /*=======================================================================*/
1045 #ifdef CONFIG_MTK_GPS
1046 struct platform_device mt3326_device_gps
= {
1047 .name
= "mt3326-gps",
1050 .platform_data
= &mt3326_gps_hw
,
1055 /*=======================================================================*/
1057 /*=======================================================================*/
1058 #if defined(CONFIG_ANDROID_PMEM)
1059 static struct android_pmem_platform_data pdata_multimedia
= {
1060 .name
= "pmem_multimedia",
1066 static struct platform_device pmem_multimedia_device
= {
1067 .name
= "android_pmem",
1069 .dev
= { .platform_data
= &pdata_multimedia
}
1073 #if defined(CONFIG_ANDROID_VMEM)
1074 static struct android_vmem_platform_data pdata_vmultimedia
= {
1075 .name
= "vmem_multimedia",
1081 static struct platform_device vmem_multimedia_device
= {
1082 .name
= "android_vmem",
1084 .dev
= { .platform_data
= &pdata_vmultimedia
}
1088 /*=======================================================================*/
1090 /*=======================================================================*/
1091 static struct platform_device camera_sysram_dev
= {
1092 .name
= "camera-sysram", /* FIXME. Sync to driver, init.rc, MHAL */
1096 /*=======================================================================*/
1097 /*=======================================================================*/
1098 /* Commandline filter */
1099 /* This function is used to filter undesired command passed from LK */
1100 /*=======================================================================*/
1101 static void cmdline_filter(struct tag
*cmdline_tag
, char *default_cmdline
)
1103 const char *undesired_cmds
[] = {
1114 cs
= cmdline_tag
->u
.cmdline
.cmdline
;
1116 while((__u32
)ce
< (__u32
)tag_next(cmdline_tag
)) {
1118 while(*cs
== ' ' || *cs
== '\0') {
1123 if (*ce
== ' ' || *ce
== '\0') {
1124 for (i
= 0; i
< sizeof(undesired_cmds
)/sizeof(char *); i
++){
1125 if (memcmp(cs
, undesired_cmds
[i
], strlen(undesired_cmds
[i
])) == 0) {
1133 //Append to the default command line
1134 strcat(default_cmdline
, " ");
1135 strcat(default_cmdline
, cs
);
1142 if (strlen(default_cmdline
) >= COMMAND_LINE_SIZE
)
1144 panic("Command line length is too long.\n\r");
1147 /*=======================================================================*/
1148 /* Parse the framebuffer info */
1149 /*=======================================================================*/
1150 static int __init
parse_tag_videofb_fixup(const struct tag
*tags
)
1152 bl_fb
.base
= tags
->u
.videolfb
.lfb_base
;
1153 bl_fb
.size
= tags
->u
.videolfb
.lfb_size
;
1158 static int __init
parse_tag_devinfo_data_fixup(const struct tag
*tags
)
1161 int size
= tags
->u
.devinfo_data
.devinfo_data_size
;
1162 for (i
=0;i
<size
;i
++){
1163 g_devinfo_data
[i
] = tags
->u
.devinfo_data
.devinfo_data
[i
];
1166 /* print chip id for debugging purpose */
1167 printk("tag_devinfo_data_rid, index[%d]:0x%x\n", 12,g_devinfo_data
[12]);
1168 printk("tag_devinfo_data size:%d\n", size
);
1169 g_devinfo_data_size
= size
;
1173 #ifdef CONFIG_MTK_MTD_NAND
1174 int __init
parse_tag_partition_fixup(const struct tag
*tags
)
1177 if(tags
->hdr
.tag
== ATAG_OTP_INFO
)
1179 otp_info
.size
= tags
->u
.tag_pt_info
.size
;
1180 otp_info
.start_address
= tags
->u
.tag_pt_info
.start_address
;
1182 if(tags
->hdr
.tag
== ATAG_BMT_INFO
)
1184 bmt_info
.size
= tags
->u
.tag_pt_info
.size
;
1185 bmt_info
.start_address
= tags
->u
.tag_pt_info
.start_address
;
1190 int __init
parse_tag_flashnum_fixup(const struct tag
*tags
)
1193 flash_number
= tags
->u
.tag_nand_number
.number
;
1194 //gen_FlashTable_p = (flashdev_info_t*) kzalloc(flash_number*sizeof(flashdev_info_t), GFP_KERNEL);
1195 gen_FlashTable_ptr
= gen_FlashTable_p
;
1199 int __init
parse_tag_flash_fixup(const struct tag
*tags
)
1201 int* p
= (int*)&tags
->u
.gen_FlashTable_p
;
1203 memcpy(gen_FlashTable_ptr
, &tags
->u
.gen_FlashTable_p
, sizeof(flashdev_info_t
));
1204 gen_FlashTable_ptr
++;
1209 extern unsigned int mtkfb_parse_dfo_setting(void *dfo_tbl
, int num
);
1211 resource_size_t bl_mem_sz
= 0;
1212 void mt_fixup(struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
1214 struct tag
*cmdline_tag
= NULL
;
1215 struct tag
*reserved_mem_bank_tag
= NULL
;
1216 struct tag
*none_tag
= NULL
;
1218 resource_size_t max_limit_size
= CONFIG_MAX_DRAM_SIZE_SUPPORT
-
1220 resource_size_t avail_dram
= 0;
1221 unsigned char md_inf_from_meta
[4] = {0};
1222 #ifdef CONFIG_MTK_TABLET_HARDWARE
1223 struct machine_desc
*mdesc
= NULL
;
1226 #if defined(CONFIG_MTK_FB)
1227 struct tag
*temp_tags
= tags
;
1228 for (; temp_tags
->hdr
.size
; temp_tags
= tag_next(temp_tags
))
1230 if(temp_tags
->hdr
.tag
== ATAG_CMDLINE
)
1231 cmdline_filter(temp_tags
, (char*)&temp_command_line
);
1235 printk(KERN_ALERT
"Load default dfo data...\n");
1237 parse_ccci_dfo_setting(&dfo_boot_default
, DFO_BOOT_COUNT
);
1238 parse_eemcs_dfo_setting(&dfo_boot_default
, DFO_BOOT_COUNT
);
1240 for (; tags
->hdr
.size
; tags
= tag_next(tags
)) {
1241 if (tags
->hdr
.tag
== ATAG_MEM
) {
1242 bl_mem_sz
+= tags
->u
.mem
.size
;
1245 * Modify the memory tag to limit available memory to
1246 * CONFIG_MAX_DRAM_SIZE_SUPPORT
1248 if (max_limit_size
> 0) {
1249 if (max_limit_size
>= tags
->u
.mem
.size
) {
1250 max_limit_size
-= tags
->u
.mem
.size
;
1251 avail_dram
+= tags
->u
.mem
.size
;
1253 tags
->u
.mem
.size
= max_limit_size
;
1254 avail_dram
+= max_limit_size
;
1258 // remove this check to avoid calcuate pmem size before we know all dram size
1259 // Assuming the minimum size of memory bank is 256MB
1260 //if (tags->u.mem.size >= (TOTAL_RESERVED_MEM_SIZE)) {
1261 reserved_mem_bank_tag
= tags
;
1264 tags
->u
.mem
.size
= 0;
1267 else if (tags
->hdr
.tag
== ATAG_CMDLINE
) {
1269 } else if (tags
->hdr
.tag
== ATAG_BOOT
) {
1270 g_boot_mode
= tags
->u
.boot
.bootmode
;
1271 } else if (tags
->hdr
.tag
== ATAG_VIDEOLFB
) {
1272 parse_tag_videofb_fixup(tags
);
1273 }else if (tags
->hdr
.tag
== ATAG_DEVINFO_DATA
){
1274 parse_tag_devinfo_data_fixup(tags
);
1276 else if(tags
->hdr
.tag
== ATAG_META_COM
)
1278 g_meta_com_type
= tags
->u
.meta_com
.meta_com_type
;
1279 g_meta_com_id
= tags
->u
.meta_com
.meta_com_id
;
1281 #ifdef CONFIG_MTK_MTD_NAND
1282 else if(tags
->hdr
.tag
== ATAG_OTP_INFO
)
1284 parse_tag_partition_fixup(tags
);
1286 else if(tags
->hdr
.tag
== ATAG_BMT_INFO
)
1288 parse_tag_partition_fixup(tags
);
1291 else if(tags
->hdr
.tag
== ATAG_FLASH_NUMBER_INFO
)
1293 parse_tag_flashnum_fixup(tags
);
1295 else if(tags
->hdr
.tag
== ATAG_FLASH_INFO
)
1297 parse_tag_flash_fixup(tags
);
1300 /*else if (tags->hdr.tag == ATAG_DFO_DATA) {
1301 parse_ccci_dfo_setting(&tags->u.dfo_data, DFO_BOOT_COUNT);
1302 parse_eemcs_dfo_setting(&tags->u.dfo_data, DFO_BOOT_COUNT);
1303 mtkfb_parse_dfo_setting(&tags->u.dfo_data, DFO_BOOT_COUNT);
1305 else if(tags
->hdr
.tag
== ATAG_MDINFO_DATA
) {
1306 printk(KERN_ALERT
"Get MD inf from META\n");
1307 printk(KERN_ALERT
"md_inf[0]=%d\n",tags
->u
.mdinfo_data
.md_type
[0]);
1308 printk(KERN_ALERT
"md_inf[1]=%d\n",tags
->u
.mdinfo_data
.md_type
[1]);
1309 printk(KERN_ALERT
"md_inf[2]=%d\n",tags
->u
.mdinfo_data
.md_type
[2]);
1310 printk(KERN_ALERT
"md_inf[3]=%d\n",tags
->u
.mdinfo_data
.md_type
[3]);
1311 md_inf_from_meta
[0]=tags
->u
.mdinfo_data
.md_type
[0];
1312 md_inf_from_meta
[1]=tags
->u
.mdinfo_data
.md_type
[1];
1313 md_inf_from_meta
[2]=tags
->u
.mdinfo_data
.md_type
[2];
1314 md_inf_from_meta
[3]=tags
->u
.mdinfo_data
.md_type
[3];
1317 #ifdef CONFIG_MTK_TABLET_HARDWARE
1318 for_each_machine_desc(mdesc
)
1319 if (8127 == mdesc
->nr
)
1324 unsigned int i
= get_devinfo_with_index(3);
1325 unsigned int j
= get_devinfo_with_index(15);
1330 strcpy((void *)mdesc
->name
, "MT8680");
1332 strcpy((void *)mdesc
->name
, "MT8685");
1336 switch ((i
>> 24) & 0xF)
1339 strcpy((void *)mdesc
->name
, "MT8127");
1342 strcpy((void *)mdesc
->name
, "MT8117");
1349 if ((g_boot_mode
== META_BOOT
) || (g_boot_mode
== ADVMETA_BOOT
)) {
1351 * Always use default dfo setting in META mode.
1352 * We can fix abnormal dfo setting this way.
1354 printk(KERN_ALERT
"(META mode) Load default dfo data...\n");
1355 parse_ccci_dfo_setting(&dfo_boot_default
, DFO_BOOT_COUNT
);
1356 parse_meta_md_setting(md_inf_from_meta
);
1357 parse_eemcs_dfo_setting(&dfo_boot_default
, DFO_BOOT_COUNT
);
1358 parse_ext_meta_md_setting(md_inf_from_meta
);
1361 kernel_mem_sz
= avail_dram
; // keep the DRAM size (limited by CONFIG_MAX_DRAM_SIZE_SUPPORT)
1363 * If the maximum memory size configured in kernel
1364 * is smaller than the actual size (passed from BL)
1365 * Still limit the maximum memory size but use the FB
1368 if (bl_mem_sz
>= (CONFIG_MAX_DRAM_SIZE_SUPPORT
- RESERVED_MEM_MODEM
)) {
1376 if (avail_dram < 0x10000000)
1377 RESERVED_MEM_SIZE_FOR_PMEM = 0x1700000;
1379 RESERVED_MEM_SIZE_FOR_PMEM
= 0x0;
1381 /* Reserve memory in the last bank */
1382 if (reserved_mem_bank_tag
) {
1383 reserved_mem_bank_tag
->u
.mem
.size
-= ((__u32
)TOTAL_RESERVED_MEM_SIZE
);
1384 if(g_boot_mode
== FACTORY_BOOT
) {
1385 /* we need to reserved the maximum FB_SIZE to get a fixed TEST_3D pa. */
1386 resource_size_t rest_fb_size
= RESERVED_MEM_SIZE_FOR_FB_MAX
- FB_SIZE
;
1387 RESERVED_MEM_SIZE_FOR_TEST_3D
= 0x9a00000 + rest_fb_size
;
1388 reserved_mem_bank_tag
->u
.mem
.size
-= RESERVED_MEM_SIZE_FOR_TEST_3D
;
1390 FB_SIZE_EXTERN
= FB_SIZE
;
1391 pmem_start
= reserved_mem_bank_tag
->u
.mem
.start
+ reserved_mem_bank_tag
->u
.mem
.size
;
1392 } else // we should always have reserved memory
1395 MTK_MEMCFG_LOG_AND_PRINTK(KERN_ALERT
1396 "[PHY layout]avaiable DRAM size (lk) = 0x%llx\n"
1397 "[PHY layout]avaiable DRAM size = 0x%llx\n"
1398 "[PHY layout]FB : 0x%llx - 0x%llx (0x%llx)\n",
1399 (unsigned long long)bl_mem_sz
,
1400 (unsigned long long)kernel_mem_sz
,
1401 (unsigned long long)FB_START
,
1402 (unsigned long long)(FB_START
+ FB_SIZE
- 1),
1403 (unsigned long long)FB_SIZE
);
1404 if(g_boot_mode
== FACTORY_BOOT
)
1405 MTK_MEMCFG_LOG_AND_PRINTK(KERN_ALERT
1406 "[PHY layout]3D : 0x%llx - 0x%llx (0x%llx)\n",
1407 (unsigned long long)TEST_3D_START
,
1408 (unsigned long long)(TEST_3D_START
+ TEST_3D_SIZE
- 1),
1409 (unsigned long long)TEST_3D_SIZE
);
1411 MTK_MEMCFG_LOG_AND_PRINTK(KERN_ALERT
1412 "[PHY layout]PMEM : 0x%llx - 0x%llx (0x%llx)\n",
1413 (unsigned long long)PMEM_MM_START
,
1414 (unsigned long long)(PMEM_MM_START
+ PMEM_MM_SIZE
- 1),
1415 (unsigned long long)PMEM_MM_SIZE
);
1418 if(tags
->hdr
.tag
== ATAG_NONE
)
1420 if (cmdline_tag
!= NULL
) {
1421 #ifdef CONFIG_FIQ_DEBUGGER
1426 // This function may modify ttyMT3 to ttyMT0 if needed
1427 adjust_kernel_cmd_line_setting_for_console(cmdline_tag
->u
.cmdline
.cmdline
, *cmdline
);
1428 #ifdef CONFIG_FIQ_DEBUGGER
1429 if ((console_ptr
=strstr(*cmdline
, "ttyMT")) != 0)
1431 uart_port
= console_ptr
[5] - '0';
1435 fiq_uart_fixup(uart_port
);
1439 cmdline_filter(cmdline_tag
, *cmdline
);
1440 if ((br_ptr
= strstr(*cmdline
, "boot_reason=")) != 0) {
1441 /* get boot reason */
1442 g_boot_reason
= br_ptr
[12] - '0';
1444 /* Use the default cmdline */
1445 memcpy((void*)cmdline_tag
,
1446 (void*)tag_next(cmdline_tag
),
1447 /* ATAG_NONE actual size */
1448 (uint32_t)(none_tag
) - (uint32_t)(tag_next(cmdline_tag
)) + 8);
1452 struct platform_device auxadc_device
= {
1453 .name
= "mt-auxadc",
1457 /*=======================================================================*/
1458 /* MT6575 sensor module */
1459 /*=======================================================================*/
1460 struct platform_device sensor_gsensor
= {
1465 struct platform_device sensor_msensor
= {
1470 struct platform_device sensor_orientation
= {
1471 .name
= "orientation",
1475 struct platform_device sensor_alsps
= {
1480 struct platform_device sensor_gyroscope
= {
1481 .name
= "gyroscope",
1485 struct platform_device sensor_barometer
= {
1486 .name
= "barometer",
1490 struct platform_device sensor_temperature
= {
1491 .name
= "temperature",
1495 struct platform_device sensor_batch
= {
1496 .name
= "batchsensor",
1501 struct platform_device hwmon_sensor
= {
1502 .name
= "hwmsensor",
1506 struct platform_device acc_sensor
= {
1510 struct platform_device mag_sensor
= {
1515 struct platform_device alsps_sensor
= {
1516 .name
= "m_alsps_pl",
1520 struct platform_device gyro_sensor
= {
1521 .name
= "m_gyro_pl",
1525 struct platform_device barometer_sensor
= {
1526 .name
= "m_baro_pl",
1530 struct platform_device temp_sensor
= {
1531 .name
= "m_temp_pl",
1535 struct platform_device batch_sensor
= {
1536 .name
= "m_batch_pl",
1541 /*=======================================================================*/
1543 /*=======================================================================*/
1544 static u64 disp_dmamask
= ~(u32
)0;
1546 static struct platform_device disp_device
= {
1550 .dma_mask
= &disp_dmamask
,
1551 .coherent_dma_mask
= 0xffffffff,
1557 /*=======================================================================*/
1559 /*=======================================================================*/
1560 static struct resource mt_resource_isp
[] = {
1561 { // ISP configuration
1562 .start
= IO_VIRT_TO_PHYS(CAMINF_BASE
),
1563 .end
= IO_VIRT_TO_PHYS(CAMINF_BASE
) + 0xE000,
1564 .flags
= IORESOURCE_MEM
,
1567 .start
= CAMERA_ISP_IRQ0_ID
,
1568 .flags
= IORESOURCE_IRQ
,
1571 static u64 mt_isp_dmamask
= ~(u32
) 0;
1573 static struct platform_device mt_isp_dev
= {
1574 .name
= "camera-isp",
1576 .num_resources
= ARRAY_SIZE(mt_resource_isp
),
1577 .resource
= mt_resource_isp
,
1579 .dma_mask
= &mt_isp_dmamask
,
1580 .coherent_dma_mask
= 0xffffffffUL
1585 /*=======================================================================*/
1587 /*=======================================================================*/
1588 static struct resource mt_resource_eis
[] = {
1589 [0] = { // EIS configuration
1591 .end
= EIS_BASE
+ 0x2C,
1592 .flags
= IORESOURCE_MEM
,
1595 static u64 mt_eis_dmamask
= ~(u32
) 0;
1597 static struct platform_device mt_eis_dev
= {
1598 .name
= "camera-eis",
1600 .num_resources
= ARRAY_SIZE(mt_resource_eis
),
1601 .resource
= mt_resource_eis
,
1603 .dma_mask
= &mt_eis_dmamask
,
1604 .coherent_dma_mask
= 0xffffffffUL
1610 /*=======================================================================*/
1612 /*=======================================================================*/
1613 static struct platform_device sensor_dev
= {
1614 .name
= "image_sensor",
1617 static struct platform_device sensor_dev_bus2
= {
1618 .name
= "image_sensor_bus2",
1623 /*=======================================================================*/
1625 /*=======================================================================*/
1626 static struct platform_device actuator_dev
= {
1627 .name
= "lens_actuator",
1630 /*=======================================================================*/
1631 /* MT6575 jogball */
1632 /*=======================================================================*/
1633 #ifdef CONFIG_MOUSE_PANASONIC_EVQWJN
1634 static struct platform_device jbd_pdev
= {
1635 .name
= "mt6575-jb",
1640 /*=======================================================================*/
1641 /* MT812 Pipe Manager */
1642 /*=======================================================================*/
1643 static struct platform_device camera_pipemgr_dev
= {
1644 .name
= "camera-pipemgr",
1648 static struct platform_device mt65xx_leds_device
= {
1649 .name
= "leds-mt65xx",
1652 /*=======================================================================*/
1654 /*=======================================================================*/
1655 static struct platform_device mtk_nfc_6605_dev
= {
1660 //#ifdef CONFIG_MTK_WIFI
1661 /*=======================================================================*/
1662 /* MT6572/82 WIFI module */
1663 /*=======================================================================*/
1664 struct platform_device mt_device_wifi
= {
1670 /*=======================================================================*/
1671 /* Unused Memory Allocation */
1672 /*=======================================================================*/
1673 #ifdef MTK_USE_RESERVED_EXT_MEM
1674 static struct platform_device mt_extmem
= {
1675 .name
= "mt-extmem",
1679 /*=======================================================================*/
1680 /* MT8127 Board Device Initialization */
1681 /* Sim switch driver */
1682 /*=======================================================================*/
1683 #if defined (CUSTOM_KERNEL_SSW)
1684 static struct platform_device ssw_device
= {
1685 .name
= "sim-switch",
1689 /*=======================================================================*/
1690 /* battery driver */
1691 /*=======================================================================*/
1692 struct platform_device battery_device
= {
1697 /*=======================================================================*/
1698 /* MT6589 Board Device Initialization */
1699 /*=======================================================================*/
1700 __init
int mt_board_init(void)
1702 int i
= 0, retval
= 0;
1704 #if defined(CONFIG_MTK_SERIAL)
1705 for (i
= 0; i
< ARRAY_SIZE(mtk_device_uart
); i
++){
1706 retval
= platform_device_register(&mtk_device_uart
[i
]);
1707 printk("register uart device\n");
1713 #ifdef CONFIG_FIQ_DEBUGGER
1714 retval
= platform_device_register(&mt_fiq_debugger
);
1722 #if defined(CONFIG_MTK_USB_UNIQUE_SERIAL) || defined(MTK_SEC_FASTBOOT_UNLOCK_SUPPORT)
1723 key
= get_devinfo_with_index(13);
1724 key
= (key
<< 32) | get_devinfo_with_index(12);
1729 get_serial(key
, get_chip_code(), serial_number
);
1731 memcpy(serial_number
, "0123456789ABCDEF", 16);
1733 retval
= kobject_init_and_add(&sn_kobj
, &sn_ktype
, NULL
, "sys_info");
1736 printk("[%s] fail to add kobject\n", "sys_info");
1739 #if defined(CONFIG_MTK_MTD_NAND)
1740 retval
= platform_device_register(&mtk_nand_dev
);
1742 printk(KERN_ERR
"register nand device fail\n");
1747 retval
= platform_device_register(&gpio_dev
);
1751 retval
= platform_device_register(&fh_dev
);
1755 #ifdef CONFIG_MTK_KEYPAD
1756 retval
= platform_device_register(&kpd_pdev
);
1762 #ifdef CONFIG_MOUSE_PANASONIC_EVQWJN
1763 retval
= platform_device_register(&jbd_pdev
);
1769 #if defined(CONFIG_KEYBOARD_HID)
1770 retval
= platform_device_register(&mt_hid_dev
);
1776 #if defined(CONFIG_MTK_WFD_SUPPORT)
1777 retval
= platform_device_register(&mt_uibc_dev
);
1783 #if defined(CONFIG_MTK_I2C)
1784 //i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
1785 //i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
1786 //i2c_register_board_info(2, i2c_devs2, ARRAY_SIZE(i2c_devs2));
1787 for (i
= 0; i
< ARRAY_SIZE(mt_device_i2c
); i
++){
1788 retval
= platform_device_register(&mt_device_i2c
[i
]);
1794 #if defined(CONFIG_MTK_MMC)
1795 for (i
= 0; i
< ARRAY_SIZE(mt_device_msdc
); i
++){
1796 retval
= platform_device_register(&mt_device_msdc
[i
]);
1803 #if defined(CONFIG_MTK_SOUND)
1804 retval
= platform_device_register(&AudDrv_device
);
1805 printk("AudDrv_driver_device \n!");
1810 retval
= platform_device_register(&AudDrv_device2
);
1811 printk("AudioMTKBTCVSD AudDrv_device2 \n!");
1813 printk("AudioMTKBTCVSD AudDrv_device2 Fail:%d \n", retval
);
1818 #if defined(CONFIG_SND_SOC_MT8127)
1819 retval
= platform_add_devices(mtk_soc_audio_devices
, ARRAY_SIZE(mtk_soc_audio_devices
));
1821 printk("platform_add_devices(mtk_soc_audio_devices) fail:%d\n", retval
);
1826 #ifdef MTK_MULTIBRIDGE_SUPPORT
1827 retval
= platform_device_register(&mtk_multibridge_dev
);
1828 printk("multibridge_driver_device \n!");
1834 retval
= platform_device_register(&mtk_device_btif
);
1835 printk("mtk_device_btif register ret %d", retval
);
1840 //=====SMI/M4U devices===========
1841 printk("register MTK_SMI device\n");
1842 retval
= platform_device_register(&mtk_smi_dev
);
1848 //===========================
1850 #ifdef MTK_MT8193_SUPPORT
1851 printk("register 8193_CKGEN device\n");
1852 retval
= platform_device_register(&mtk_ckgen_dev
);
1855 printk("register 8193_CKGEN device FAILS!\n");
1860 //=======================================================================
1862 //=======================================================================
1864 retval
= platform_device_register(&disp_device
);
1871 printk("register M4U device: %d\n", retval
);
1872 retval
= platform_device_register(&mtk_m4u_dev
);
1878 #if defined(CONFIG_MTK_FB)
1880 * Bypass matching the frame buffer info. between boot loader and kernel
1881 * if the limited memory size of the kernel is smaller than the
1882 * memory size from bootloader
1884 if (((bl_fb
.base
== FB_START
) && (bl_fb
.size
== FB_SIZE
)) ||
1886 printk(KERN_ALERT
"FB is initialized by BL(%d)\n", use_bl_fb
);
1887 mtkfb_set_lcm_inited(1);
1888 } else if ((bl_fb
.base
== 0) && (bl_fb
.size
== 0)) {
1889 printk(KERN_ALERT
"FB is not initialized(%d)\n", use_bl_fb
);
1890 mtkfb_set_lcm_inited(0);
1893 "******************************************************************************\n"
1894 " WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n"
1895 "******************************************************************************\n"
1897 " The default FB base & size values are not matched between BL and kernel\n"
1898 " - BOOTLD: start 0x%08x, size %d\n"
1899 " - KERNEL: start 0x%llx, size %lld\n"
1901 " If you see this warning message, please update your uboot.\n"
1903 "******************************************************************************\n"
1904 " WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING\n"
1905 "******************************************************************************\n"
1906 "\n", bl_fb
.base
, bl_fb
.size
, (unsigned long long)FB_START
, (unsigned long long)FB_SIZE
);
1907 /* workaround for TEST_3D_START */
1908 mtkfb_set_lcm_inited(1);
1912 while (delay_sec
>= 0) {
1913 printk("\rcontinue after %d seconds ...", delay_sec
--);
1919 panic("The default base & size values are not matched "
1920 "between BL and kernel\n");
1924 resource_fb
[0].start
= FB_START
;
1925 resource_fb
[0].end
= FB_START
+ FB_SIZE
- 1;
1927 printk(KERN_ALERT
"FB start: 0x%x end: 0x%x\n", resource_fb
[0].start
,
1928 resource_fb
[0].end
);
1930 retval
= platform_device_register(&mt6575_device_fb
);
1936 #if defined(CONFIG_MTK_LEDS)
1937 retval
= platform_device_register(&mt65xx_leds_device
);
1940 printk("bei:device LEDS register\n");
1943 #ifdef CONFIG_MTK_HDMI_SUPPORT
1944 retval
= platform_device_register(&mtk_hdmi_dev
);
1951 #if defined(CONFIG_MTK_SPI)
1952 // spi_register_board_info(spi_board_devs, ARRAY_SIZE(spi_board_devs));
1953 platform_device_register(&mt_spi_device
);
1961 #if defined(MTK_TVOUT_SUPPORT)
1962 retval
= platform_device_register(&mt6575_TVOUT_dev
);
1963 printk("register TV-out device\n");
1970 retval
= platform_device_register(&auxadc_device
);
1973 printk("****[auxadc_driver] Unable to device register(%d)\n", retval
);
1978 #if defined(CONFIG_MTK_ACCDET)
1981 retval
= platform_device_register(&accdet_device
);
1982 printk("register accdet device\n");
1986 printk("platform_device_accdet_register error:(%d)\n", retval
);
1991 printk("platform_device_accdet_register done!\n");
1996 #if defined(CONFIG_USB_MTK_ACM_TEMP)
1998 retval
= platform_device_register(&usbacm_temp_device
);
1999 printk("register usbacm temp device\n");
2003 printk("platform_device_usbacm_register error:(%d)\n", retval
);
2008 printk("platform_device_usbacm_register done!\n");
2014 #if 0 //defined(CONFIG_MDP_MT6575)
2015 //printk("[MDP]platform_device_register\n\r");
2016 retval
= platform_device_register(&mt6575_MDP_dev
);
2022 #if defined(CONFIG_MTK_SENSOR_SUPPORT)
2024 retval
= platform_device_register(&hwmon_sensor
);
2025 printk("hwmon_sensor device!");
2029 retval
= platform_device_register(&batch_sensor
);
2030 printk("[%s]: batch_sensor, retval=%d \n!", __func__
, retval
);
2034 retval
= platform_device_register(&acc_sensor
);
2035 printk("[%s]: acc_sensor, retval=%d \n!", __func__
, retval
);
2039 retval
= platform_device_register(&mag_sensor
);
2040 printk("[%s]: mag_sensor, retval=%d \n!", __func__
, retval
);
2044 retval
= platform_device_register(&gyro_sensor
);
2045 printk("[%s]: gyro_sensor, retval=%d \n!", __func__
, retval
);
2049 retval
= platform_device_register(&alsps_sensor
);
2050 printk("[%s]: alsps_sensor, retval=%d \n!", __func__
, retval
);
2054 retval
= platform_device_register(&barometer_sensor
);
2055 printk("[%s]: barometer_sensor, retval=%d \n!", __func__
, retval
);
2059 retval
= platform_device_register(&temp_sensor
);
2060 printk("[%s]: temp_sensor, retval=%d \n!", __func__
, retval
);
2064 #if defined(CONFIG_CUSTOM_KERNEL_ACCELEROMETER)
2065 retval
= platform_device_register(&sensor_gsensor
);
2066 printk("sensor_gsensor device!");
2071 #if defined(CONFIG_CUSTOM_KERNEL_MAGNETOMETER)
2072 retval
= platform_device_register(&sensor_msensor
);
2073 printk("sensor_msensor device!");
2077 retval
= platform_device_register(&sensor_orientation
);
2078 printk("sensor_osensor device!");
2084 #if defined(CONFIG_CUSTOM_KERNEL_GYROSCOPE)
2085 retval
= platform_device_register(&sensor_gyroscope
);
2086 printk("sensor_gyroscope device!");
2091 #if defined(CONFIG_CUSTOM_KERNEL_BAROMETER)
2092 retval
= platform_device_register(&sensor_barometer
);
2093 printk("sensor_barometer device!");
2098 #if defined(CONFIG_CUSTOM_KERNEL_ALSPS)
2099 retval
= platform_device_register(&sensor_alsps
);
2100 printk("sensor_alsps device!");
2105 #if defined(CONFIG_CUSTOM_KERNEL_TEMPERATURE)
2106 retval
= platform_device_register(&sensor_temperature
);
2107 printk("[%s]: sensor_temperature, retval=%d \n!", __func__
, retval
);
2108 printk("sensor_temperature device!");
2114 #if defined(CONFIG_MTK_USBFSH)
2115 printk("register musbfsh device\n");
2116 retval
= platform_device_register(&mt_usb11_dev
);
2118 printk("register musbfsh device fail!\n");
2123 #if defined(CONFIG_USB_MTK_HDRC)
2124 printk("mt_device_usb register\n");
2125 retval
= platform_device_register(&mt_device_usb
);
2127 printk("mt_device_usb register fail\n");
2132 #if 1 // init after USB driver
2133 retval
= platform_device_register(&battery_device
);
2135 printk("[battery_driver] Unable to device register\n");
2140 #if defined(CONFIG_MTK_TOUCHPANEL)
2141 retval
= platform_device_register(&mtk_tpd_dev
);
2146 #if defined(CUSTOM_KERNEL_OFN)
2147 retval
= platform_device_register(&ofn_driver
);
2153 #if (defined(CONFIG_MTK_MTD_NAND) ||defined(CONFIG_MTK_MMC))
2154 retval
= platform_device_register(&dummychar_device
);
2161 #if defined(CONFIG_ANDROID_PMEM)
2162 pdata_multimedia
.start
= PMEM_MM_START
;;
2163 pdata_multimedia
.size
= PMEM_MM_SIZE
;
2164 printk("PMEM start: 0x%lx size: 0x%lx\n", pdata_multimedia
.start
, pdata_multimedia
.size
);
2166 retval
= platform_device_register(&pmem_multimedia_device
);
2172 #if defined(CONFIG_ANDROID_VMEM)
2173 pdata_vmultimedia
.start
= PMEM_MM_START
;;
2174 pdata_vmultimedia
.size
= PMEM_MM_SIZE
;
2175 printk("VMEM start: 0x%lx size: 0x%lx\n", pdata_vmultimedia
.start
, pdata_vmultimedia
.size
);
2177 retval
= platform_device_register(&vmem_multimedia_device
);
2179 printk("vmem platform register failed\n");
2184 #ifdef CONFIG_CPU_FREQ
2185 retval
= platform_device_register(&cpufreq_pdev
);
2192 retval
= platform_device_register(&thermal_pdev
);
2199 retval
= platform_device_register(&mtk_therm_mon_pdev
);
2205 retval
= platform_device_register(&ptp_pdev
);
2210 retval
= platform_device_register(&spm_mcdi_pdev
);
2216 //=======================================================================
2218 //=======================================================================
2219 #if 1 ///defined(CONFIG_VIDEO_CAPTURE_DRIVERS)
2220 retval
= platform_device_register(&sensor_dev
);
2225 #if 1 ///defined(CONFIG_VIDEO_CAPTURE_DRIVERS)
2226 retval
= platform_device_register(&sensor_dev_bus2
);
2233 //=======================================================================
2235 //=======================================================================
2236 #if 1 //defined(CONFIG_ACTUATOR)
2237 retval
= platform_device_register(&actuator_dev
);
2246 //=======================================================================
2248 //=======================================================================
2249 #if 1 //defined(CONFIG_ISP_MT8127)
2250 retval
= platform_device_register(&mt_isp_dev
);
2257 retval
= platform_device_register(&mt_eis_dev
);
2263 #ifdef CONFIG_RFKILL
2264 retval
= platform_device_register(&mt_rfkill_device
);
2271 retval
= platform_device_register(&camera_sysram_dev
);
2277 #if defined(CONFIG_MTK_GPS)
2278 retval
= platform_device_register(&mt3326_device_gps
);
2284 retval
= platform_device_register(&camera_pipemgr_dev
);
2290 #if defined(CONFIG_MTK_NFC) //NFC
2291 retval
= platform_device_register(&mtk_nfc_6605_dev
);
2292 printk("mtk_nfc_6605_dev register ret %d", retval
);
2298 //#if defined(CONFIG_MTK_WIFI)
2299 retval
= platform_device_register(&mt_device_wifi
);
2305 #if defined (CUSTOM_KERNEL_SSW)
2306 retval
= platform_device_register(&ssw_device
);
2312 #ifdef CONFIG_MTK_USE_RESERVED_EXT_MEM
2313 retval
= platform_device_register(&mt_extmem
);
2315 printk("%s[%d] ret: %d\n", __FILE__
, __LINE__
, retval
);
2321 retval
= platform_device_register(&masp_device
);
2332 * base: buffer base physical address
2333 * size: buffer len in byte
2335 * 1: buffer is located in pmem address range
2336 * 0: buffer is out of pmem address range
2338 int is_pmem_range(unsigned long *base
, unsigned long size
)
2340 unsigned long start
= (unsigned long)base
;
2341 unsigned long end
= start
+ size
;
2343 //printk("[PMEM] start=0x%p,end=0x%p,size=%d\n", start, end, size);
2344 //printk("[PMEM] PMEM_MM_START=0x%p,PMEM_MM_SIZE=%d\n", PMEM_MM_START, PMEM_MM_SIZE);
2346 if (start
< PMEM_MM_START
)
2348 if (end
>= PMEM_MM_START
+ PMEM_MM_SIZE
)
2353 EXPORT_SYMBOL(is_pmem_range
);
2355 // return the actual physical DRAM size
2356 unsigned int mtk_get_max_DRAM_size(void)
2358 return kernel_mem_sz
+ RESERVED_MEM_MODEM
;
2361 resource_size_t
get_actual_DRAM_size(void)
2365 EXPORT_SYMBOL(get_actual_DRAM_size
);
2367 #include <asm/sections.h>
2368 void get_text_region (unsigned int *s
, unsigned int *e
)
2370 *s
= (unsigned int)_text
, *e
=(unsigned int)_etext
;
2372 EXPORT_SYMBOL(get_text_region
) ;
2374 void __weak
mtk_wcn_consys_memory_reserve(void)
2376 printk(KERN_ERR
"weak reserve function: %s", __FUNCTION__
);
2379 void __weak
eemcs_memory_reserve(void)
2381 printk(KERN_ERR
"calling weak function %s\n", __FUNCTION__
);
2384 void mt_reserve(void)
2386 // aee_dram_console_reserve_memory();
2387 mrdump_reserve_memory();
2389 #if defined(CONFIG_MTK_RAM_CONSOLE_USING_DRAM)
2390 memblock_reserve(CONFIG_MTK_RAM_CONSOLE_DRAM_ADDR
, CONFIG_MTK_RAM_CONSOLE_DRAM_SIZE
);
2392 mrdump_mini_reserve_memory();
2395 * Dynamic reserved memory (by arm_memblock_steal)
2397 * *** DO NOT CHANGE THE RESERVE ORDER ***
2399 * New memory reserve functions should be APPENDED to old funtions
2401 mtk_wcn_consys_memory_reserve();
2402 ccci_md_mem_reserve();
2403 #if defined(CONFIG_MTK_EEMCS_DEVICES)
2404 eemcs_memory_reserve();
2406 /* Last line of dynamic reserve functions */