pb1100.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Pb1100 board platform device registration
  3. *
  4. * Copyright (C) 2009 Manuel Lauss
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/delay.h>
  21. #include <linux/gpio.h>
  22. #include <linux/init.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/dma-mapping.h>
  25. #include <linux/platform_device.h>
  26. #include <asm/mach-au1x00/au1000.h>
  27. #include <asm/mach-db1x00/bcsr.h>
  28. #include <prom.h>
  29. #include "platform.h"
  30. const char *get_system_type(void)
  31. {
  32. return "PB1100";
  33. }
  34. void __init board_setup(void)
  35. {
  36. volatile void __iomem *base = (volatile void __iomem *)0xac000000UL;
  37. bcsr_init(DB1000_BCSR_PHYS_ADDR,
  38. DB1000_BCSR_PHYS_ADDR + DB1000_BCSR_HEXLED_OFS);
  39. /* Set AUX clock to 12 MHz * 8 = 96 MHz */
  40. au_writel(8, SYS_AUXPLL);
  41. alchemy_gpio1_input_enable();
  42. udelay(100);
  43. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  44. {
  45. u32 pin_func, sys_freqctrl, sys_clksrc;
  46. /* Configure pins GPIO[14:9] as GPIO */
  47. pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3;
  48. /* Zero and disable FREQ2 */
  49. sys_freqctrl = au_readl(SYS_FREQCTRL0);
  50. sys_freqctrl &= ~0xFFF00000;
  51. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  52. /* Zero and disable USBH/USBD/IrDA clock */
  53. sys_clksrc = au_readl(SYS_CLKSRC);
  54. sys_clksrc &= ~(SYS_CS_CIR | SYS_CS_DIR | SYS_CS_MIR_MASK);
  55. au_writel(sys_clksrc, SYS_CLKSRC);
  56. sys_freqctrl = au_readl(SYS_FREQCTRL0);
  57. sys_freqctrl &= ~0xFFF00000;
  58. sys_clksrc = au_readl(SYS_CLKSRC);
  59. sys_clksrc &= ~(SYS_CS_CIR | SYS_CS_DIR | SYS_CS_MIR_MASK);
  60. /* FREQ2 = aux / 2 = 48 MHz */
  61. sys_freqctrl |= (0 << SYS_FC_FRDIV2_BIT) |
  62. SYS_FC_FE2 | SYS_FC_FS2;
  63. au_writel(sys_freqctrl, SYS_FREQCTRL0);
  64. /*
  65. * Route 48 MHz FREQ2 into USBH/USBD/IrDA
  66. */
  67. sys_clksrc |= SYS_CS_MUX_FQ2 << SYS_CS_MIR_BIT;
  68. au_writel(sys_clksrc, SYS_CLKSRC);
  69. /* Setup the static bus controller */
  70. au_writel(0x00000002, MEM_STCFG3); /* type = PCMCIA */
  71. au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */
  72. au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */
  73. /*
  74. * Get USB Functionality pin state (device vs host drive pins).
  75. */
  76. pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_USB;
  77. /* 2nd USB port is USB host. */
  78. pin_func |= SYS_PF_USB;
  79. au_writel(pin_func, SYS_PINFUNC);
  80. }
  81. #endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
  82. /* Enable sys bus clock divider when IDLE state or no bus activity. */
  83. au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);
  84. /* Enable the RTC if not already enabled. */
  85. if (!(readb(base + 0x28) & 0x20)) {
  86. writeb(readb(base + 0x28) | 0x20, base + 0x28);
  87. au_sync();
  88. }
  89. /* Put the clock in BCD mode. */
  90. if (readb(base + 0x2C) & 0x4) { /* reg B */
  91. writeb(readb(base + 0x2c) & ~0x4, base + 0x2c);
  92. au_sync();
  93. }
  94. }
  95. /******************************************************************************/
  96. static struct resource au1100_lcd_resources[] = {
  97. [0] = {
  98. .start = AU1100_LCD_PHYS_ADDR,
  99. .end = AU1100_LCD_PHYS_ADDR + 0x800 - 1,
  100. .flags = IORESOURCE_MEM,
  101. },
  102. [1] = {
  103. .start = AU1100_LCD_INT,
  104. .end = AU1100_LCD_INT,
  105. .flags = IORESOURCE_IRQ,
  106. }
  107. };
  108. static u64 au1100_lcd_dmamask = DMA_BIT_MASK(32);
  109. static struct platform_device au1100_lcd_device = {
  110. .name = "au1100-lcd",
  111. .id = 0,
  112. .dev = {
  113. .dma_mask = &au1100_lcd_dmamask,
  114. .coherent_dma_mask = DMA_BIT_MASK(32),
  115. },
  116. .num_resources = ARRAY_SIZE(au1100_lcd_resources),
  117. .resource = au1100_lcd_resources,
  118. };
  119. static int __init pb1100_dev_init(void)
  120. {
  121. int swapped;
  122. irq_set_irq_type(AU1100_GPIO9_INT, IRQF_TRIGGER_LOW); /* PCCD# */
  123. irq_set_irq_type(AU1100_GPIO10_INT, IRQF_TRIGGER_LOW); /* PCSTSCHG# */
  124. irq_set_irq_type(AU1100_GPIO11_INT, IRQF_TRIGGER_LOW); /* PCCard# */
  125. irq_set_irq_type(AU1100_GPIO13_INT, IRQF_TRIGGER_LOW); /* DC_IRQ# */
  126. /* PCMCIA. single socket, identical to Pb1500 */
  127. db1x_register_pcmcia_socket(
  128. AU1000_PCMCIA_ATTR_PHYS_ADDR,
  129. AU1000_PCMCIA_ATTR_PHYS_ADDR + 0x000400000 - 1,
  130. AU1000_PCMCIA_MEM_PHYS_ADDR,
  131. AU1000_PCMCIA_MEM_PHYS_ADDR + 0x000400000 - 1,
  132. AU1000_PCMCIA_IO_PHYS_ADDR,
  133. AU1000_PCMCIA_IO_PHYS_ADDR + 0x000010000 - 1,
  134. AU1100_GPIO11_INT, AU1100_GPIO9_INT, /* card / insert */
  135. /*AU1100_GPIO10_INT*/0, 0, 0); /* stschg / eject / id */
  136. swapped = bcsr_read(BCSR_STATUS) & BCSR_STATUS_DB1000_SWAPBOOT;
  137. db1x_register_norflash(64 * 1024 * 1024, 4, swapped);
  138. platform_device_register(&au1100_lcd_device);
  139. return 0;
  140. }
  141. device_initcall(pb1100_dev_init);