blob: eb96009e21c4ce3fcf07d93b61b7fe354882444f [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -04002#ifndef __ARCH_ORION5X_COMMON_H
3#define __ARCH_ORION5X_COMMON_H
4
Robin Holt7b6d8642013-07-08 16:01:40 -07005#include <linux/reboot.h>
6
Florian Fainelli575e93f2017-02-04 13:02:45 -08007struct dsa_chip_data;
Lennert Buytenhek044f6c72008-04-22 05:37:12 +02008struct mv643xx_eth_platform_data;
9struct mv_sata_platform_data;
10
Thomas Petazzoni4ca2c042013-07-26 10:17:42 -030011#define ORION_MBUS_PCIE_MEM_TARGET 0x04
12#define ORION_MBUS_PCIE_MEM_ATTR 0x59
13#define ORION_MBUS_PCIE_IO_TARGET 0x04
14#define ORION_MBUS_PCIE_IO_ATTR 0x51
15#define ORION_MBUS_PCIE_WA_TARGET 0x04
16#define ORION_MBUS_PCIE_WA_ATTR 0x79
17#define ORION_MBUS_PCI_MEM_TARGET 0x03
18#define ORION_MBUS_PCI_MEM_ATTR 0x59
19#define ORION_MBUS_PCI_IO_TARGET 0x03
20#define ORION_MBUS_PCI_IO_ATTR 0x51
21#define ORION_MBUS_DEVBUS_BOOT_TARGET 0x01
22#define ORION_MBUS_DEVBUS_BOOT_ATTR 0x0f
23#define ORION_MBUS_DEVBUS_TARGET(cs) 0x01
24#define ORION_MBUS_DEVBUS_ATTR(cs) (~(1 << cs))
Thomas Petazzoni1cc9d482014-04-13 16:39:38 +020025#define ORION_MBUS_SRAM_TARGET 0x09
Thomas Petazzoni4ca2c042013-07-26 10:17:42 -030026#define ORION_MBUS_SRAM_ATTR 0x00
27
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040028/*
29 * Basic Orion init functions used early by machine-setup.
30 */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040031void orion5x_map_io(void);
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +020032void orion5x_init_early(void);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040033void orion5x_init_irq(void);
34void orion5x_init(void);
Thomas Petazzoni1bffb4a82012-11-16 16:39:45 +010035void orion5x_id(u32 *dev, u32 *rev, char **dev_name);
36void clk_init(void);
Lennert Buytenhekebe35af2008-08-29 05:55:51 +020037extern int orion5x_tclk;
Stephen Warren6bb27d72012-11-08 12:40:59 -070038extern void orion5x_timer_init(void);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040039
Thomas Petazzoni5d1190e2013-03-21 17:59:18 +010040void orion5x_setup_wins(void);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040041
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020042void orion5x_ehci0_init(void);
43void orion5x_ehci1_init(void);
44void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);
Florian Fainelli575e93f2017-02-04 13:02:45 -080045void orion5x_eth_switch_init(struct dsa_chip_data *d);
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020046void orion5x_i2c_init(void);
47void orion5x_sata_init(struct mv_sata_platform_data *sata_data);
Lennert Buytenhekd323ade2008-08-29 06:55:06 +020048void orion5x_spi_init(void);
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020049void orion5x_uart0_init(void);
50void orion5x_uart1_init(void);
Saeed Bishara1d5a1a62008-06-16 23:25:12 -110051void orion5x_xor_init(void);
Robin Holt7b6d8642013-07-08 16:01:40 -070052void orion5x_restart(enum reboot_mode, const char *);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040053
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020054/*
55 * PCIe/PCI functions.
56 */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040057struct pci_bus;
Lorenzo Pieralisi97ad2bd2017-06-28 15:13:55 -050058struct pci_host_bridge;
Lennert Buytenhek044f6c72008-04-22 05:37:12 +020059struct pci_sys_data;
Andrew Lunn6ed272f2012-05-10 13:25:33 +020060struct pci_dev;
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040061
62void orion5x_pcie_id(u32 *dev, u32 *rev);
Per Andersson7a6bb262008-08-11 12:00:52 +020063void orion5x_pci_disable(void);
Lennert Buytenhekda01bba2008-06-26 17:12:50 +020064void orion5x_pci_set_cardbus_mode(void);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040065int orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys);
Lorenzo Pieralisi97ad2bd2017-06-28 15:13:55 -050066int orion5x_pci_sys_scan_bus(int nr, struct pci_host_bridge *bridge);
Ralf Baechled5341942011-06-10 15:30:21 +010067int orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040068
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040069struct tag;
Laura Abbott1c2f87c2014-04-13 22:54:58 +010070extern void __init tag_fixup_mem32(struct tag *, char **);
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040071
Thomas Petazzonifbf04d82014-04-22 23:26:40 +020072#ifdef CONFIG_MACH_MSS2_DT
73extern void mss2_init(void);
74#else
75static inline void mss2_init(void) {}
76#endif
77
Rob Herring8a52dd42012-02-10 18:29:09 -060078/*****************************************************************************
79 * Helpers to access Orion registers
80 ****************************************************************************/
81/*
82 * These are not preempt-safe. Locks, if needed, must be taken
83 * care of by the caller.
84 */
85#define orion5x_setbits(r, mask) writel(readl(r) | (mask), (r))
86#define orion5x_clrbits(r, mask) writel(readl(r) & ~(mask), (r))
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040087
88#endif