1a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* 2a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * Copyright (C) 2009 Cisco Systems, Inc. 3a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * 4a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * This program is free software; you can redistribute it and/or modify 5a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * it under the terms of the GNU General Public License as published by 6a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * the Free Software Foundation; either version 2 of the License, or 7a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * (at your option) any later version. 8a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * 9a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * This program is distributed in the hope that it will be useful, 10a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * GNU General Public License for more details. 13a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * 14a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * You should have received a copy of the GNU General Public License 15a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * along with this program; if not, write to the Free Software 16a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn */ 18a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 19a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#ifndef __ASM_MACH_POWERTV_ASIC_H_ 20a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define __ASM_MACH_POWERTV_ASIC_H_ 21a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#include <linux/io.h> 22a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 23a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* ASIC types */ 24a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehnenum asic_type { 25a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn ASIC_UNKNOWN, 26a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn ASIC_ZEUS, 27a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn ASIC_CALLIOPE, 28a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn ASIC_CRONUS, 29a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn ASIC_CRONUSLITE, 3051f1336d4dbd0935d873761f7f267c3f5abc9bd6David VomLehn ASIC_GAIA, 3151f1336d4dbd0935d873761f7f267c3f5abc9bd6David VomLehn ASICS /* Number of supported ASICs */ 32a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn}; 33a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 34a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* hardcoded values read from Chip Version registers */ 35a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define CRONUS_10 0x0B4C1C20 36a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define CRONUS_11 0x0B4C1C21 37a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define CRONUSLITE_10 0x0B4C1C40 38a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 3959dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define NAND_FLASH_BASE 0x03000000 40a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define CALLIOPE_IO_BASE 0x08000000 4151f1336d4dbd0935d873761f7f267c3f5abc9bd6David VomLehn#define GAIA_IO_BASE 0x09000000 4259dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define CRONUS_IO_BASE 0x09000000 4359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define ZEUS_IO_BASE 0x09000000 4459dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn 4559dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define ASIC_IO_SIZE 0x01000000 46a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 47a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* Definitions for backward compatibility */ 48a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_INTSTAT uart1_intstat 49a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_INTEN uart1_inten 50a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_CONFIG1 uart1_config1 51a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_CONFIG2 uart1_config2 52a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_DIVISORHI uart1_divisorhi 53a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_DIVISORLO uart1_divisorlo 54a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_DATA uart1_data 55a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define UART1_STATUS uart1_status 56a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 57a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* ASIC register enumeration */ 5859dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehnunion register_map_entry { 5959dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn unsigned long phys; 6059dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn u32 *virt; 6159dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn}; 6259dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn 6359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define REGISTER_MAP_ELEMENT(x) union register_map_entry x; 64a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehnstruct register_map { 6559dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#include <asm/mach-powertv/asic_reg_map.h> 66a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn}; 6759dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#undef REGISTER_MAP_ELEMENT 6859dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn 6959dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn/** 7059dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * register_map_offset_phys - add an offset to the physical address 7159dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * @map: Pointer to the &struct register_map 7259dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * @offset: Value to add 7359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * 7459dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * Only adds the base to non-zero physical addresses 7559dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn */ 7659dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehnstatic inline void register_map_offset_phys(struct register_map *map, 7759dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn unsigned long offset) 7859dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn{ 7959dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define REGISTER_MAP_ELEMENT(x) do { \ 8059dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn if (map->x.phys != 0) \ 8159dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn map->x.phys += offset; \ 8259dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn } while (false); 8359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn 8459dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#include <asm/mach-powertv/asic_reg_map.h> 8559dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#undef REGISTER_MAP_ELEMENT 8659dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn} 8759dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn 8859dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn/** 8959dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * register_map_virtualize - Convert ®ister_map to virtual addresses 9059dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn * @map: Pointer to ®ister_map to virtualize 9159dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn */ 9259dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehnstatic inline void register_map_virtualize(struct register_map *map) 9359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn{ 9459dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define REGISTER_MAP_ELEMENT(x) do { \ 9559dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn map->x.virt = (!map->x.phys) ? NULL : \ 9659dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn UNCAC_ADDR(phys_to_virt(map->x.phys)); \ 9759dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn } while (false); 9859dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn 9959dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#include <asm/mach-powertv/asic_reg_map.h> 10059dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#undef REGISTER_MAP_ELEMENT 10159dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn} 102a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 10359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehnextern struct register_map _asic_register_map; 1040d365753d0b7c26043fdfa97790411606fb40112David VomLehnextern unsigned long asic_phy_base; 105a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 106a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* 107a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * Macros to interface to registers through their ioremapped address 108a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * asic_reg_phys_addr Returns the physical address of the given register 109a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * asic_reg_addr Returns the iomapped virtual address of the given 110a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * register. 111a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn */ 11259dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define asic_reg_addr(x) (_asic_register_map.x.virt) 11359dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn#define asic_reg_phys_addr(x) (virt_to_phys((void *) CAC_ADDR( \ 11459dfa2fcaecc39fb88bfa196cb15adca7146867aDavid VomLehn (unsigned long) asic_reg_addr(x)))) 115a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 116a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn/* 117a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * The asic_reg macro is gone. It should be replaced by either asic_read or 118a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn * asic_write, as appropriate. 119a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn */ 120a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 121a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define asic_read(x) readl(asic_reg_addr(x)) 122a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#define asic_write(v, x) writel(v, asic_reg_addr(x)) 123a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn 124a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehnextern void asic_irq_init(void); 125a3a0f8c8ed2e2470f4dcd6da95020d41fed84747David VomLehn#endif 126