snappercl15.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * arch/arm/mach-ep93xx/snappercl15.c
  3. * Bluewater Systems Snapper CL15 system module
  4. *
  5. * Copyright (C) 2009 Bluewater Systems Ltd
  6. * Author: Ryan Mallon
  7. *
  8. * NAND code adapted from driver by:
  9. * Andre Renaud <andre@bluewatersys.com>
  10. * James R. McKaskill
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or (at
  15. * your option) any later version.
  16. *
  17. */
  18. #include <linux/platform_device.h>
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <linux/i2c.h>
  23. #include <linux/i2c-gpio.h>
  24. #include <linux/fb.h>
  25. #include <linux/mtd/partitions.h>
  26. #include <linux/mtd/nand.h>
  27. #include <mach/hardware.h>
  28. #include <mach/fb.h>
  29. #include <mach/gpio-ep93xx.h>
  30. #include <asm/hardware/vic.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
  34. #define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */
  35. #define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */
  36. #define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */
  37. #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */
  38. #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */
  39. #define NAND_CTRL_ADDR(chip) (chip->IO_ADDR_W + 0x40)
  40. static void snappercl15_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
  41. unsigned int ctrl)
  42. {
  43. struct nand_chip *chip = mtd->priv;
  44. static u16 nand_state = SNAPPERCL15_NAND_WPN;
  45. u16 set;
  46. if (ctrl & NAND_CTRL_CHANGE) {
  47. set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN;
  48. if (ctrl & NAND_NCE)
  49. set &= ~SNAPPERCL15_NAND_CEN;
  50. if (ctrl & NAND_CLE)
  51. set |= SNAPPERCL15_NAND_CLE;
  52. if (ctrl & NAND_ALE)
  53. set |= SNAPPERCL15_NAND_ALE;
  54. nand_state &= ~(SNAPPERCL15_NAND_CEN |
  55. SNAPPERCL15_NAND_CLE |
  56. SNAPPERCL15_NAND_ALE);
  57. nand_state |= set;
  58. __raw_writew(nand_state, NAND_CTRL_ADDR(chip));
  59. }
  60. if (cmd != NAND_CMD_NONE)
  61. __raw_writew((cmd & 0xff) | nand_state, chip->IO_ADDR_W);
  62. }
  63. static int snappercl15_nand_dev_ready(struct mtd_info *mtd)
  64. {
  65. struct nand_chip *chip = mtd->priv;
  66. return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);
  67. }
  68. static const char *snappercl15_nand_part_probes[] = {"cmdlinepart", NULL};
  69. static struct mtd_partition snappercl15_nand_parts[] = {
  70. {
  71. .name = "Kernel",
  72. .offset = 0,
  73. .size = SZ_2M,
  74. },
  75. {
  76. .name = "Filesystem",
  77. .offset = MTDPART_OFS_APPEND,
  78. .size = MTDPART_SIZ_FULL,
  79. },
  80. };
  81. static struct platform_nand_data snappercl15_nand_data = {
  82. .chip = {
  83. .nr_chips = 1,
  84. .part_probe_types = snappercl15_nand_part_probes,
  85. .partitions = snappercl15_nand_parts,
  86. .nr_partitions = ARRAY_SIZE(snappercl15_nand_parts),
  87. .options = NAND_NO_AUTOINCR,
  88. .chip_delay = 25,
  89. },
  90. .ctrl = {
  91. .dev_ready = snappercl15_nand_dev_ready,
  92. .cmd_ctrl = snappercl15_nand_cmd_ctrl,
  93. },
  94. };
  95. static struct resource snappercl15_nand_resource[] = {
  96. {
  97. .start = SNAPPERCL15_NAND_BASE,
  98. .end = SNAPPERCL15_NAND_BASE + SZ_4K - 1,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. };
  102. static struct platform_device snappercl15_nand_device = {
  103. .name = "gen_nand",
  104. .id = -1,
  105. .dev.platform_data = &snappercl15_nand_data,
  106. .resource = snappercl15_nand_resource,
  107. .num_resources = ARRAY_SIZE(snappercl15_nand_resource),
  108. };
  109. static struct ep93xx_eth_data __initdata snappercl15_eth_data = {
  110. .phy_id = 1,
  111. };
  112. static struct i2c_gpio_platform_data __initdata snappercl15_i2c_gpio_data = {
  113. .sda_pin = EP93XX_GPIO_LINE_EEDAT,
  114. .sda_is_open_drain = 0,
  115. .scl_pin = EP93XX_GPIO_LINE_EECLK,
  116. .scl_is_open_drain = 0,
  117. .udelay = 0,
  118. .timeout = 0,
  119. };
  120. static struct i2c_board_info __initdata snappercl15_i2c_data[] = {
  121. {
  122. /* Audio codec */
  123. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  124. },
  125. };
  126. static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = {
  127. .num_modes = EP93XXFB_USE_MODEDB,
  128. .bpp = 16,
  129. };
  130. static struct platform_device snappercl15_audio_device = {
  131. .name = "snappercl15-audio",
  132. .id = -1,
  133. };
  134. static void __init snappercl15_register_audio(void)
  135. {
  136. ep93xx_register_i2s();
  137. platform_device_register(&snappercl15_audio_device);
  138. }
  139. static void __init snappercl15_init_machine(void)
  140. {
  141. ep93xx_init_devices();
  142. ep93xx_register_eth(&snappercl15_eth_data, 1);
  143. ep93xx_register_i2c(&snappercl15_i2c_gpio_data, snappercl15_i2c_data,
  144. ARRAY_SIZE(snappercl15_i2c_data));
  145. ep93xx_register_fb(&snappercl15_fb_info);
  146. snappercl15_register_audio();
  147. platform_device_register(&snappercl15_nand_device);
  148. }
  149. MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15")
  150. /* Maintainer: Ryan Mallon */
  151. .atag_offset = 0x100,
  152. .map_io = ep93xx_map_io,
  153. .init_irq = ep93xx_init_irq,
  154. .handle_irq = vic_handle_irq,
  155. .timer = &ep93xx_timer,
  156. .init_machine = snappercl15_init_machine,
  157. .restart = ep93xx_restart,
  158. MACHINE_END