platform.c 4.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/*
 * Pb1200/DBAu1200 board platform device registration
 *
 * Copyright (C) 2008 MontaVista Software Inc. <source@mvista.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

21
#include <linux/dma-mapping.h>
22
#include <linux/init.h>
23
#include <linux/leds.h>
24
#include <linux/platform_device.h>
25
#include <linux/smc91x.h>
26 27

#include <asm/mach-au1x00/au1xxx.h>
28
#include <asm/mach-au1x00/au1100_mmc.h>
29
#include <asm/mach-db1x00/bcsr.h>
30 31 32 33 34 35

static int mmc_activity;

static void pb1200mmc0_set_power(void *mmc_host, int state)
{
	if (state)
36
		bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD0PWR);
37
	else
38
		bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD0PWR, 0);
39

40
	msleep(1);
41 42 43 44
}

static int pb1200mmc0_card_readonly(void *mmc_host)
{
45
	return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD0WP) ? 1 : 0;
46 47 48 49
}

static int pb1200mmc0_card_inserted(void *mmc_host)
{
50
	return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD0INSERT) ? 1 : 0;
51 52 53 54 55 56 57
}

static void pb1200_mmcled_set(struct led_classdev *led,
			enum led_brightness brightness)
{
	if (brightness != LED_OFF) {
		if (++mmc_activity == 1)
58
			bcsr_mod(BCSR_LEDS, BCSR_LEDS_LED0, 0);
59 60
	} else {
		if (--mmc_activity == 0)
61
			bcsr_mod(BCSR_LEDS, 0, BCSR_LEDS_LED0);
62 63 64 65 66 67 68 69 70 71 72
	}
}

static struct led_classdev pb1200mmc_led = {
	.brightness_set	= pb1200_mmcled_set,
};

#ifndef CONFIG_MIPS_DB1200
static void pb1200mmc1_set_power(void *mmc_host, int state)
{
	if (state)
73
		bcsr_mod(BCSR_BOARD, 0, BCSR_BOARD_SD1PWR);
74
	else
75
		bcsr_mod(BCSR_BOARD, BCSR_BOARD_SD1PWR, 0);
76

77
	msleep(1);
78 79 80 81
}

static int pb1200mmc1_card_readonly(void *mmc_host)
{
82
	return (bcsr_read(BCSR_STATUS) & BCSR_STATUS_SD1WP) ? 1 : 0;
83 84 85 86
}

static int pb1200mmc1_card_inserted(void *mmc_host)
{
87
	return (bcsr_read(BCSR_SIGSTAT) & BCSR_INT_SD1INSERT) ? 1 : 0;
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
}
#endif

const struct au1xmmc_platform_data au1xmmc_platdata[2] = {
	[0] = {
		.set_power	= pb1200mmc0_set_power,
		.card_inserted	= pb1200mmc0_card_inserted,
		.card_readonly	= pb1200mmc0_card_readonly,
		.cd_setup	= NULL,		/* use poll-timer in driver */
		.led		= &pb1200mmc_led,
	},
#ifndef CONFIG_MIPS_DB1200
	[1] = {
		.set_power	= pb1200mmc1_set_power,
		.card_inserted	= pb1200mmc1_card_inserted,
		.card_readonly	= pb1200mmc1_card_readonly,
		.cd_setup	= NULL,		/* use poll-timer in driver */
		.led		= &pb1200mmc_led,
	},
#endif
};
109 110 111 112 113 114 115 116 117 118 119 120 121 122

static struct resource ide_resources[] = {
	[0] = {
		.start	= IDE_PHYS_ADDR,
		.end 	= IDE_PHYS_ADDR + IDE_PHYS_LEN - 1,
		.flags	= IORESOURCE_MEM
	},
	[1] = {
		.start	= IDE_INT,
		.end	= IDE_INT,
		.flags	= IORESOURCE_IRQ
	}
};

123
static u64 ide_dmamask = DMA_BIT_MASK(32);
124 125 126 127 128 129

static struct platform_device ide_device = {
	.name		= "au1200-ide",
	.id		= 0,
	.dev = {
		.dma_mask 		= &ide_dmamask,
130
		.coherent_dma_mask	= DMA_BIT_MASK(32),
131 132 133 134 135
	},
	.num_resources	= ARRAY_SIZE(ide_resources),
	.resource	= ide_resources
};

136 137 138 139 140 141
static struct smc91x_platdata smc_data = {
	.flags	= SMC91X_NOWAIT | SMC91X_USE_16BIT,
	.leda	= RPC_LED_100_10,
	.ledb	= RPC_LED_TX_RX,
};

142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
static struct resource smc91c111_resources[] = {
	[0] = {
		.name	= "smc91x-regs",
		.start	= SMC91C111_PHYS_ADDR,
		.end	= SMC91C111_PHYS_ADDR + 0xf,
		.flags	= IORESOURCE_MEM
	},
	[1] = {
		.start	= SMC91C111_INT,
		.end	= SMC91C111_INT,
		.flags	= IORESOURCE_IRQ
	},
};

static struct platform_device smc91c111_device = {
157 158 159
	.dev	= {
		.platform_data	= &smc_data,
	},
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
	.name		= "smc91x",
	.id		= -1,
	.num_resources	= ARRAY_SIZE(smc91c111_resources),
	.resource	= smc91c111_resources
};

static struct platform_device *board_platform_devices[] __initdata = {
	&ide_device,
	&smc91c111_device
};

static int __init board_register_devices(void)
{
	return platform_add_devices(board_platform_devices,
				    ARRAY_SIZE(board_platform_devices));
}

arch_initcall(board_register_devices);