snappercl15.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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/fb.h>
  24. #include <linux/mtd/platnand.h>
  25. #include <mach/hardware.h>
  26. #include <linux/platform_data/video-ep93xx.h>
  27. #include <mach/gpio-ep93xx.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include "soc.h"
  31. #define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
  32. #define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */
  33. #define SNAPPERCL15_NAND_ALE (1 << 9) /* Address latch */
  34. #define SNAPPERCL15_NAND_CLE (1 << 10) /* Command latch */
  35. #define SNAPPERCL15_NAND_CEN (1 << 11) /* Chip enable (active low) */
  36. #define SNAPPERCL15_NAND_RDY (1 << 14) /* Device ready */
  37. #define NAND_CTRL_ADDR(chip) (chip->legacy.IO_ADDR_W + 0x40)
  38. static void snappercl15_nand_cmd_ctrl(struct nand_chip *chip, int cmd,
  39. unsigned int ctrl)
  40. {
  41. static u16 nand_state = SNAPPERCL15_NAND_WPN;
  42. u16 set;
  43. if (ctrl & NAND_CTRL_CHANGE) {
  44. set = SNAPPERCL15_NAND_CEN | SNAPPERCL15_NAND_WPN;
  45. if (ctrl & NAND_NCE)
  46. set &= ~SNAPPERCL15_NAND_CEN;
  47. if (ctrl & NAND_CLE)
  48. set |= SNAPPERCL15_NAND_CLE;
  49. if (ctrl & NAND_ALE)
  50. set |= SNAPPERCL15_NAND_ALE;
  51. nand_state &= ~(SNAPPERCL15_NAND_CEN |
  52. SNAPPERCL15_NAND_CLE |
  53. SNAPPERCL15_NAND_ALE);
  54. nand_state |= set;
  55. __raw_writew(nand_state, NAND_CTRL_ADDR(chip));
  56. }
  57. if (cmd != NAND_CMD_NONE)
  58. __raw_writew((cmd & 0xff) | nand_state,
  59. chip->legacy.IO_ADDR_W);
  60. }
  61. static int snappercl15_nand_dev_ready(struct nand_chip *chip)
  62. {
  63. return !!(__raw_readw(NAND_CTRL_ADDR(chip)) & SNAPPERCL15_NAND_RDY);
  64. }
  65. static struct mtd_partition snappercl15_nand_parts[] = {
  66. {
  67. .name = "Kernel",
  68. .offset = 0,
  69. .size = SZ_2M,
  70. },
  71. {
  72. .name = "Filesystem",
  73. .offset = MTDPART_OFS_APPEND,
  74. .size = MTDPART_SIZ_FULL,
  75. },
  76. };
  77. static struct platform_nand_data snappercl15_nand_data = {
  78. .chip = {
  79. .nr_chips = 1,
  80. .partitions = snappercl15_nand_parts,
  81. .nr_partitions = ARRAY_SIZE(snappercl15_nand_parts),
  82. .chip_delay = 25,
  83. },
  84. .ctrl = {
  85. .dev_ready = snappercl15_nand_dev_ready,
  86. .cmd_ctrl = snappercl15_nand_cmd_ctrl,
  87. },
  88. };
  89. static struct resource snappercl15_nand_resource[] = {
  90. {
  91. .start = SNAPPERCL15_NAND_BASE,
  92. .end = SNAPPERCL15_NAND_BASE + SZ_4K - 1,
  93. .flags = IORESOURCE_MEM,
  94. },
  95. };
  96. static struct platform_device snappercl15_nand_device = {
  97. .name = "gen_nand",
  98. .id = -1,
  99. .dev.platform_data = &snappercl15_nand_data,
  100. .resource = snappercl15_nand_resource,
  101. .num_resources = ARRAY_SIZE(snappercl15_nand_resource),
  102. };
  103. static struct ep93xx_eth_data __initdata snappercl15_eth_data = {
  104. .phy_id = 1,
  105. };
  106. static struct i2c_board_info __initdata snappercl15_i2c_data[] = {
  107. {
  108. /* Audio codec */
  109. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  110. },
  111. };
  112. static struct ep93xxfb_mach_info __initdata snappercl15_fb_info = {
  113. };
  114. static struct platform_device snappercl15_audio_device = {
  115. .name = "snappercl15-audio",
  116. .id = -1,
  117. };
  118. static void __init snappercl15_register_audio(void)
  119. {
  120. ep93xx_register_i2s();
  121. platform_device_register(&snappercl15_audio_device);
  122. }
  123. static void __init snappercl15_init_machine(void)
  124. {
  125. ep93xx_init_devices();
  126. ep93xx_register_eth(&snappercl15_eth_data, 1);
  127. ep93xx_register_i2c(snappercl15_i2c_data,
  128. ARRAY_SIZE(snappercl15_i2c_data));
  129. ep93xx_register_fb(&snappercl15_fb_info);
  130. snappercl15_register_audio();
  131. platform_device_register(&snappercl15_nand_device);
  132. }
  133. MACHINE_START(SNAPPER_CL15, "Bluewater Systems Snapper CL15")
  134. /* Maintainer: Ryan Mallon */
  135. .atag_offset = 0x100,
  136. .map_io = ep93xx_map_io,
  137. .init_irq = ep93xx_init_irq,
  138. .init_time = ep93xx_timer_init,
  139. .init_machine = snappercl15_init_machine,
  140. .init_late = ep93xx_init_late,
  141. .restart = ep93xx_restart,
  142. MACHINE_END