Blame view

kernel/linux-imx6_3.14.28/arch/arm/mach-gemini/devices.c 2.79 KB
6b13f685e   김민수   BSP 최초 추가
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
  /*
   * Common devices definition for Gemini
   *
   * Copyright (C) 2008-2009 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/io.h>
  #include <linux/platform_device.h>
  #include <linux/serial_8250.h>
  #include <linux/mtd/physmap.h>
  
  #include <mach/irqs.h>
  #include <mach/hardware.h>
  #include <mach/global_reg.h>
  
  static struct plat_serial8250_port serial_platform_data[] = {
  	{
  		.membase	= (void *)IO_ADDRESS(GEMINI_UART_BASE),
  		.mapbase	= GEMINI_UART_BASE,
  		.irq		= IRQ_UART,
  		.uartclk	= UART_CLK,
  		.regshift	= 2,
  		.iotype		= UPIO_MEM,
  		.type		= PORT_16550A,
  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_FIXED_TYPE,
  	},
  	{},
  };
  
  static struct platform_device serial_device = {
  	.name	= "serial8250",
  	.id	= PLAT8250_DEV_PLATFORM,
  	.dev	= {
  		.platform_data = serial_platform_data,
  	},
  };
  
  int platform_register_uart(void)
  {
  	return platform_device_register(&serial_device);
  }
  
  static struct resource flash_resource = {
  	.start	= GEMINI_FLASH_BASE,
  	.flags	= IORESOURCE_MEM,
  };
  
  static struct physmap_flash_data pflash_platform_data = {};
  
  static struct platform_device pflash_device = {
  	.name	= "physmap-flash",
  	.id	= 0,
  	.dev 	= {
  		.platform_data = &pflash_platform_data,
  	},
  	.resource = &flash_resource,
  	.num_resources = 1,
  };
  
  int platform_register_pflash(unsigned int size, struct mtd_partition *parts,
  			     unsigned int nr_parts)
  {
  	unsigned int reg;
  
  	reg = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_STATUS);
  
  	if ((reg & FLASH_TYPE_MASK) != FLASH_TYPE_PARALLEL)
  		return -ENXIO;
  
  	if (reg & FLASH_WIDTH_16BIT)
  		pflash_platform_data.width = 2;
  	else
  		pflash_platform_data.width = 1;
  
  	/* enable parallel flash pins and disable others */
  	reg = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
  	reg &= ~PFLASH_PADS_DISABLE;
  	reg |= SFLASH_PADS_DISABLE | NAND_PADS_DISABLE;
  	__raw_writel(reg, IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
  
  	flash_resource.end = flash_resource.start + size - 1;
  
  	pflash_platform_data.parts = parts;
  	pflash_platform_data.nr_parts = nr_parts;
  
  	return platform_device_register(&pflash_device);
  }
  
  static struct resource gemini_rtc_resources[] = {
  	[0] = {
  		.start  = GEMINI_RTC_BASE,
  		.end    = GEMINI_RTC_BASE + 0x24,
  		.flags  = IORESOURCE_MEM,
  	},
  	[1] = {
  		.start  = IRQ_RTC,
  		.end    = IRQ_RTC,
  		.flags  = IORESOURCE_IRQ,
  	},
  };
  
  static struct platform_device gemini_rtc_device = {
  	.name		= "rtc-gemini",
  	.id		= 0,
  	.num_resources	= ARRAY_SIZE(gemini_rtc_resources),
  	.resource	= gemini_rtc_resources,
  };
  
  int __init platform_register_rtc(void)
  {
  	return platform_device_register(&gemini_rtc_device);
  }