pb1100.c 4.9 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * Pb1100 board platform device registration
L
Linus Torvalds 已提交
3
 *
4
 * Copyright (C) 2009 Manuel Lauss
L
Linus Torvalds 已提交
5
 *
6 7 8 9
 * 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.
L
Linus Torvalds 已提交
10
 *
11 12 13 14 15 16 17 18
 * 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
L
Linus Torvalds 已提交
19
 */
20

21
#include <linux/delay.h>
22
#include <linux/gpio.h>
L
Linus Torvalds 已提交
23
#include <linux/init.h>
24
#include <linux/interrupt.h>
25 26
#include <linux/dma-mapping.h>
#include <linux/platform_device.h>
L
Linus Torvalds 已提交
27
#include <asm/mach-au1x00/au1000.h>
28
#include <asm/mach-db1x00/bcsr.h>
29
#include <prom.h>
30
#include "platform.h"
31 32 33

const char *get_system_type(void)
{
34
	return "PB1100";
35 36
}

L
Linus Torvalds 已提交
37 38
void __init board_setup(void)
{
39
	volatile void __iomem *base = (volatile void __iomem *)0xac000000UL;
40

41 42 43
	bcsr_init(DB1000_BCSR_PHYS_ADDR,
		  DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);

44
	/* Set AUX clock to 12 MHz * 8 = 96 MHz */
L
Linus Torvalds 已提交
45
	au_writel(8, SYS_AUXPLL);
46
	alchemy_gpio1_input_enable();
L
Linus Torvalds 已提交
47 48
	udelay(100);

49
#if IS_ENABLED(CONFIG_USB_OHCI_HCD)
50 51 52
	{
		u32 pin_func, sys_freqctrl, sys_clksrc;

53 54
		/* Configure pins GPIO[14:9] as GPIO */
		pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3;
55

56
		/* Zero and disable FREQ2 */
57 58 59 60
		sys_freqctrl = au_readl(SYS_FREQCTRL0);
		sys_freqctrl &= ~0xFFF00000;
		au_writel(sys_freqctrl, SYS_FREQCTRL0);

61
		/* Zero and disable USBH/USBD/IrDA clock */
62
		sys_clksrc = au_readl(SYS_CLKSRC);
63
		sys_clksrc &= ~(SYS_CS_CIR | SYS_CS_DIR | SYS_CS_MIR_MASK);
64 65 66 67 68 69
		au_writel(sys_clksrc, SYS_CLKSRC);

		sys_freqctrl = au_readl(SYS_FREQCTRL0);
		sys_freqctrl &= ~0xFFF00000;

		sys_clksrc = au_readl(SYS_CLKSRC);
70
		sys_clksrc &= ~(SYS_CS_CIR | SYS_CS_DIR | SYS_CS_MIR_MASK);
71

72 73 74
		/* FREQ2 = aux / 2 = 48 MHz */
		sys_freqctrl |= (0 << SYS_FC_FRDIV2_BIT) |
				SYS_FC_FE2 | SYS_FC_FS2;
75 76 77
		au_writel(sys_freqctrl, SYS_FREQCTRL0);

		/*
78
		 * Route 48 MHz FREQ2 into USBH/USBD/IrDA
79
		 */
80
		sys_clksrc |= SYS_CS_MUX_FQ2 << SYS_CS_MIR_BIT;
81 82
		au_writel(sys_clksrc, SYS_CLKSRC);

83
		/* Setup the static bus controller */
84 85 86 87
		au_writel(0x00000002, MEM_STCFG3);  /* type = PCMCIA */
		au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */
		au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */

88 89 90 91 92 93
		/*
		 * Get USB Functionality pin state (device vs host drive pins).
		 */
		pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_USB;
		/* 2nd USB port is USB host. */
		pin_func |= SYS_PF_USB;
94 95
		au_writel(pin_func, SYS_PINFUNC);
	}
96
#endif /* IS_ENABLED(CONFIG_USB_OHCI_HCD) */
L
Linus Torvalds 已提交
97 98 99 100

	/* Enable sys bus clock divider when IDLE state or no bus activity. */
	au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);

101
	/* Enable the RTC if not already enabled. */
102 103
	if (!(readb(base + 0x28) & 0x20)) {
		writeb(readb(base + 0x28) | 0x20, base + 0x28);
L
Linus Torvalds 已提交
104 105
		au_sync();
	}
106
	/* Put the clock in BCD mode. */
107 108
	if (readb(base + 0x2C) & 0x4) { /* reg B */
		writeb(readb(base + 0x2c) & ~0x4, base + 0x2c);
L
Linus Torvalds 已提交
109 110 111
		au_sync();
	}
}
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
/******************************************************************************/

static struct resource au1100_lcd_resources[] = {
	[0] = {
		.start	= AU1100_LCD_PHYS_ADDR,
		.end	= AU1100_LCD_PHYS_ADDR + 0x800 - 1,
		.flags	= IORESOURCE_MEM,
	},
	[1] = {
		.start	= AU1100_LCD_INT,
		.end	= AU1100_LCD_INT,
		.flags	= IORESOURCE_IRQ,
	}
};

static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);

static struct platform_device au1100_lcd_device = {
	.name		= "au1100-lcd",
	.id		= 0,
	.dev = {
		.dma_mask		= &au1100_lcd_dmamask,
		.coherent_dma_mask	= DMA_BIT_MASK(32),
	},
	.num_resources	= ARRAY_SIZE(au1100_lcd_resources),
	.resource	= au1100_lcd_resources,
};

static int __init pb1100_dev_init(void)
142
{
143 144
	int swapped;

145 146 147 148
	irq_set_irq_type(AU1100_GPIO9_INT, IRQF_TRIGGER_LOW); /* PCCD# */
	irq_set_irq_type(AU1100_GPIO10_INT, IRQF_TRIGGER_LOW); /* PCSTSCHG# */
	irq_set_irq_type(AU1100_GPIO11_INT, IRQF_TRIGGER_LOW); /* PCCard# */
	irq_set_irq_type(AU1100_GPIO13_INT, IRQF_TRIGGER_LOW); /* DC_IRQ# */
149

150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
	/* PCMCIA. single socket, identical to Pb1500 */
	db1x_register_pcmcia_socket(
		AU1000_PCMCIA_ATTR_PHYS_ADDR,
		AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
		AU1000_PCMCIA_MEM_PHYS_ADDR,
		AU1000_PCMCIA_MEM_PHYS_ADDR  + 0x000400000 - 1,
		AU1000_PCMCIA_IO_PHYS_ADDR,
		AU1000_PCMCIA_IO_PHYS_ADDR   + 0x000010000 - 1,
		AU1100_GPIO11_INT, AU1100_GPIO9_INT,	 /* card / insert */
		/*AU1100_GPIO10_INT*/0, 0, 0); /* stschg / eject / id */

	swapped = bcsr_read(BCSR_STATUS) &  BCSR_STATUS_DB1000_SWAPBOOT;
	db1x_register_norflash(64 * 1024 * 1024, 4, swapped);
	platform_device_register(&au1100_lcd_device);

165 166
	return 0;
}
167
device_initcall(pb1100_dev_init);