summaryrefslogtreecommitdiffstats
path: root/target/linux/adm5120/files-2.6.26/arch/mips/adm5120/compex/compex.c
blob: 10120d6226d4b7e41edc6ab3b59e45e377a5c6ce (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
/*
 *  Compex boards
 *
 *  Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
 *
 *  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/gpio.h>

#include <asm/bootinfo.h>

#include <asm/mach-adm5120/adm5120_info.h>
#include <asm/mach-adm5120/adm5120_board.h>
#include <asm/mach-adm5120/adm5120_platform.h>
#include <asm/mach-adm5120/adm5120_irq.h>

#include <asm/mach-adm5120/prom/myloader.h>

#include "compex.h"

#define COMPEX_GPIO_DEV_MASK	(1 << ADM5120_GPIO_PIN5)

static void switch_bank_gpio5(unsigned bank)
{
	switch (bank) {
	case 0:
		gpio_set_value(ADM5120_GPIO_PIN5, 0);
		break;
	case 1:
		gpio_set_value(ADM5120_GPIO_PIN5, 1);
		break;
	}
}

void __init compex_mac_setup(void)
{
	int i, j;

	if (!myloader_present())
		return;

	for (i = 0; i < 6; i++)
		for (j = 0; j < 6; j++)
			adm5120_eth_macs[i][j] = myloader_info.macs[i][j];
}

void __init compex_generic_setup(void)
{
	gpio_request(ADM5120_GPIO_PIN5, NULL); /* for flash A20 line */
	gpio_direction_output(ADM5120_GPIO_PIN5, 0);

	adm5120_flash0_data.switch_bank = switch_bank_gpio5;
	adm5120_add_device_flash(0);

	adm5120_add_device_gpio(COMPEX_GPIO_DEV_MASK);

	compex_mac_setup();
}