summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/colibri-pxa300.c
blob: 7cc4249c770157f32580bf0096145ead25577dbe (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 *  arch/arm/mach-pxa/colibri-pxa300.c
 *
 *  Support for Toradex PXA300 based Colibri module
 *  Daniel Mack <daniel@caiaq.de>
 *
 *  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/init.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <net/ax88796.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/irq.h>

#include <mach/pxa300.h>
#include <mach/colibri.h>
#include <mach/mmc.h>

#include "generic.h"
#include "devices.h"

/*
 * GPIO configuration
 */
static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = {
	GPIO1_nCS2,			/* AX88796 chip select */
	GPIO26_GPIO | MFP_PULL_HIGH,	/* AX88796 IRQ */

#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
	GPIO7_MMC1_CLK,
	GPIO14_MMC1_CMD,
	GPIO3_MMC1_DAT0,
	GPIO4_MMC1_DAT1,
	GPIO5_MMC1_DAT2,
	GPIO6_MMC1_DAT3,
#endif
};

#if defined(CONFIG_AX88796)
/*
 * Asix AX88796 Ethernet
 */
static struct ax_plat_data colibri_asix_platdata = {
	.flags		= AXFLG_MAC_FROMDEV,
	.wordlength	= 2,
	.dcr_val	= 0x01,
	.rcr_val	= 0x0e,
	.gpoc_val	= 0x19
};

static struct resource colibri_asix_resource[] = {
	[0] = {
		.start = PXA3xx_CS2_PHYS,
		.end   = PXA3xx_CS2_PHYS + (0x18 * 0x2) - 1,
		.flags = IORESOURCE_MEM,
	},
	[1] = {
		.start = PXA3xx_CS2_PHYS + (1 << 11),
		.end   = PXA3xx_CS2_PHYS + (1 << 11) + 0x3fff,
		.flags = IORESOURCE_MEM,
	},
	[2] = {
		.start = COLIBRI_PXA300_ETH_IRQ,
		.end   = COLIBRI_PXA300_ETH_IRQ,
		.flags = IORESOURCE_IRQ
	}
};

static struct platform_device asix_device = {
	.name		= "ax88796",
	.id		= 0,
	.num_resources 	= ARRAY_SIZE(colibri_asix_resource),
	.resource	= colibri_asix_resource,
	.dev		= {
		.platform_data = &colibri_asix_platdata
	}
};
#endif /* CONFIG_AX88796 */

static struct platform_device *colibri_pxa300_devices[] __initdata = {
#if defined(CONFIG_AX88796)
	&asix_device
#endif
};

#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
#define MMC_DETECT_PIN   mfp_to_gpio(MFP_PIN_GPIO13)

static int colibri_pxa300_mci_init(struct device *dev,
				   irq_handler_t colibri_mmc_detect_int,
				   void *data)
{
	int ret;

	ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
	if (ret)
		return ret;

	gpio_direction_input(MMC_DETECT_PIN);
	ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
			  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			  "MMC card detect", data);
	if (ret) {
		gpio_free(MMC_DETECT_PIN);
		return ret;
	}

	return 0;
}

static void colibri_pxa300_mci_exit(struct device *dev, void *data)
{
	free_irq(MMC_DETECT_PIN, data);
	gpio_free(gpio_to_irq(MMC_DETECT_PIN));
}

static struct pxamci_platform_data colibri_pxa300_mci_platform_data = {
	.detect_delay	= 20,
	.ocr_mask	= MMC_VDD_32_33 | MMC_VDD_33_34,
	.init		= colibri_pxa300_mci_init,
	.exit		= colibri_pxa300_mci_exit,
};

static void __init colibri_pxa300_init_mmc(void)
{
	pxa_set_mci_info(&colibri_pxa300_mci_platform_data);
}

#else
static inline void colibri_pxa300_init_mmc(void) {}
#endif /* CONFIG_MMC_PXA */

static void __init colibri_pxa300_init(void)
{
	set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING);
	pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
	platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
	colibri_pxa300_init_mmc();
}

MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")
	.phys_io	= 0x40000000,
	.io_pg_offst	= (io_p2v(0x40000000) >> 18) & 0xfffc,
	.boot_params	= COLIBRI_SDRAM_BASE + 0x100,
	.init_machine	= colibri_pxa300_init,
	.map_io		= pxa_map_io,
	.init_irq	= pxa3xx_init_irq,
	.timer		= &pxa_timer,
MACHINE_END