asic_regs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (C) 2009 Cisco Systems, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __ASM_MACH_POWERTV_ASIC_H_
  19. #define __ASM_MACH_POWERTV_ASIC_H_
  20. #include <linux/io.h>
  21. /* ASIC types */
  22. enum asic_type {
  23. ASIC_UNKNOWN,
  24. ASIC_ZEUS,
  25. ASIC_CALLIOPE,
  26. ASIC_CRONUS,
  27. ASIC_CRONUSLITE,
  28. ASICS
  29. };
  30. /* hardcoded values read from Chip Version registers */
  31. #define CRONUS_10 0x0B4C1C20
  32. #define CRONUS_11 0x0B4C1C21
  33. #define CRONUSLITE_10 0x0B4C1C40
  34. #define NAND_FLASH_BASE 0x03000000
  35. #define CALLIOPE_IO_BASE 0x08000000
  36. #define CRONUS_IO_BASE 0x09000000
  37. #define ZEUS_IO_BASE 0x09000000
  38. #define ASIC_IO_SIZE 0x01000000
  39. /* Definitions for backward compatibility */
  40. #define UART1_INTSTAT uart1_intstat
  41. #define UART1_INTEN uart1_inten
  42. #define UART1_CONFIG1 uart1_config1
  43. #define UART1_CONFIG2 uart1_config2
  44. #define UART1_DIVISORHI uart1_divisorhi
  45. #define UART1_DIVISORLO uart1_divisorlo
  46. #define UART1_DATA uart1_data
  47. #define UART1_STATUS uart1_status
  48. /* ASIC register enumeration */
  49. union register_map_entry {
  50. unsigned long phys;
  51. u32 *virt;
  52. };
  53. #define REGISTER_MAP_ELEMENT(x) union register_map_entry x;
  54. struct register_map {
  55. #include <asm/mach-powertv/asic_reg_map.h>
  56. };
  57. #undef REGISTER_MAP_ELEMENT
  58. /**
  59. * register_map_offset_phys - add an offset to the physical address
  60. * @map: Pointer to the &struct register_map
  61. * @offset: Value to add
  62. *
  63. * Only adds the base to non-zero physical addresses
  64. */
  65. static inline void register_map_offset_phys(struct register_map *map,
  66. unsigned long offset)
  67. {
  68. #define REGISTER_MAP_ELEMENT(x) do { \
  69. if (map->x.phys != 0) \
  70. map->x.phys += offset; \
  71. } while (false);
  72. #include <asm/mach-powertv/asic_reg_map.h>
  73. #undef REGISTER_MAP_ELEMENT
  74. }
  75. /**
  76. * register_map_virtualize - Convert &register_map to virtual addresses
  77. * @map: Pointer to &register_map to virtualize
  78. */
  79. static inline void register_map_virtualize(struct register_map *map)
  80. {
  81. #define REGISTER_MAP_ELEMENT(x) do { \
  82. map->x.virt = (!map->x.phys) ? NULL : \
  83. UNCAC_ADDR(phys_to_virt(map->x.phys)); \
  84. } while (false);
  85. #include <asm/mach-powertv/asic_reg_map.h>
  86. #undef REGISTER_MAP_ELEMENT
  87. }
  88. extern struct register_map _asic_register_map;
  89. /*
  90. * Macros to interface to registers through their ioremapped address
  91. * asic_reg_phys_addr Returns the physical address of the given register
  92. * asic_reg_addr Returns the iomapped virtual address of the given
  93. * register.
  94. */
  95. #define asic_reg_addr(x) (_asic_register_map.x.virt)
  96. #define asic_reg_phys_addr(x) (virt_to_phys((void *) CAC_ADDR( \
  97. (unsigned long) asic_reg_addr(x))))
  98. /*
  99. * The asic_reg macro is gone. It should be replaced by either asic_read or
  100. * asic_write, as appropriate.
  101. */
  102. #define asic_read(x) readl(asic_reg_addr(x))
  103. #define asic_write(v, x) writel(v, asic_reg_addr(x))
  104. extern void asic_irq_init(void);
  105. #endif