18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __ARCH_ORION5X_COMMON_H
38c2ecf20Sopenharmony_ci#define __ARCH_ORION5X_COMMON_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/reboot.h>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cistruct dsa_chip_data;
88c2ecf20Sopenharmony_cistruct mv643xx_eth_platform_data;
98c2ecf20Sopenharmony_cistruct mv_sata_platform_data;
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define ORION_MBUS_PCIE_MEM_TARGET    0x04
128c2ecf20Sopenharmony_ci#define ORION_MBUS_PCIE_MEM_ATTR      0x59
138c2ecf20Sopenharmony_ci#define ORION_MBUS_PCIE_IO_TARGET     0x04
148c2ecf20Sopenharmony_ci#define ORION_MBUS_PCIE_IO_ATTR       0x51
158c2ecf20Sopenharmony_ci#define ORION_MBUS_PCIE_WA_TARGET     0x04
168c2ecf20Sopenharmony_ci#define ORION_MBUS_PCIE_WA_ATTR       0x79
178c2ecf20Sopenharmony_ci#define ORION_MBUS_PCI_MEM_TARGET     0x03
188c2ecf20Sopenharmony_ci#define ORION_MBUS_PCI_MEM_ATTR       0x59
198c2ecf20Sopenharmony_ci#define ORION_MBUS_PCI_IO_TARGET      0x03
208c2ecf20Sopenharmony_ci#define ORION_MBUS_PCI_IO_ATTR        0x51
218c2ecf20Sopenharmony_ci#define ORION_MBUS_DEVBUS_BOOT_TARGET 0x01
228c2ecf20Sopenharmony_ci#define ORION_MBUS_DEVBUS_BOOT_ATTR   0x0f
238c2ecf20Sopenharmony_ci#define ORION_MBUS_DEVBUS_TARGET(cs)  0x01
248c2ecf20Sopenharmony_ci#define ORION_MBUS_DEVBUS_ATTR(cs)    (~(1 << cs))
258c2ecf20Sopenharmony_ci#define ORION_MBUS_SRAM_TARGET        0x09
268c2ecf20Sopenharmony_ci#define ORION_MBUS_SRAM_ATTR          0x00
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/*
298c2ecf20Sopenharmony_ci * Basic Orion init functions used early by machine-setup.
308c2ecf20Sopenharmony_ci */
318c2ecf20Sopenharmony_civoid orion5x_map_io(void);
328c2ecf20Sopenharmony_civoid orion5x_init_early(void);
338c2ecf20Sopenharmony_civoid orion5x_init_irq(void);
348c2ecf20Sopenharmony_civoid orion5x_init(void);
358c2ecf20Sopenharmony_civoid orion5x_id(u32 *dev, u32 *rev, char **dev_name);
368c2ecf20Sopenharmony_civoid clk_init(void);
378c2ecf20Sopenharmony_ciextern int orion5x_tclk;
388c2ecf20Sopenharmony_ciextern void orion5x_timer_init(void);
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_civoid orion5x_setup_wins(void);
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_civoid orion5x_ehci0_init(void);
438c2ecf20Sopenharmony_civoid orion5x_ehci1_init(void);
448c2ecf20Sopenharmony_civoid orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);
458c2ecf20Sopenharmony_civoid orion5x_eth_switch_init(struct dsa_chip_data *d);
468c2ecf20Sopenharmony_civoid orion5x_i2c_init(void);
478c2ecf20Sopenharmony_civoid orion5x_sata_init(struct mv_sata_platform_data *sata_data);
488c2ecf20Sopenharmony_civoid orion5x_spi_init(void);
498c2ecf20Sopenharmony_civoid orion5x_uart0_init(void);
508c2ecf20Sopenharmony_civoid orion5x_uart1_init(void);
518c2ecf20Sopenharmony_civoid orion5x_xor_init(void);
528c2ecf20Sopenharmony_civoid orion5x_restart(enum reboot_mode, const char *);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * PCIe/PCI functions.
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_cistruct pci_bus;
588c2ecf20Sopenharmony_cistruct pci_host_bridge;
598c2ecf20Sopenharmony_cistruct pci_sys_data;
608c2ecf20Sopenharmony_cistruct pci_dev;
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_civoid orion5x_pcie_id(u32 *dev, u32 *rev);
638c2ecf20Sopenharmony_civoid orion5x_pci_disable(void);
648c2ecf20Sopenharmony_civoid orion5x_pci_set_cardbus_mode(void);
658c2ecf20Sopenharmony_ciint orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys);
668c2ecf20Sopenharmony_ciint orion5x_pci_sys_scan_bus(int nr, struct pci_host_bridge *bridge);
678c2ecf20Sopenharmony_ciint orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cistruct tag;
708c2ecf20Sopenharmony_ciextern void __init tag_fixup_mem32(struct tag *, char **);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#ifdef CONFIG_MACH_MSS2_DT
738c2ecf20Sopenharmony_ciextern void mss2_init(void);
748c2ecf20Sopenharmony_ci#else
758c2ecf20Sopenharmony_cistatic inline void mss2_init(void) {}
768c2ecf20Sopenharmony_ci#endif
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#ifdef CONFIG_MACH_D2NET_DT
798c2ecf20Sopenharmony_civoid d2net_init(void);
808c2ecf20Sopenharmony_ci#else
818c2ecf20Sopenharmony_cistatic inline void d2net_init(void) {}
828c2ecf20Sopenharmony_ci#endif
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/*****************************************************************************
858c2ecf20Sopenharmony_ci * Helpers to access Orion registers
868c2ecf20Sopenharmony_ci ****************************************************************************/
878c2ecf20Sopenharmony_ci/*
888c2ecf20Sopenharmony_ci * These are not preempt-safe.  Locks, if needed, must be taken
898c2ecf20Sopenharmony_ci * care of by the caller.
908c2ecf20Sopenharmony_ci */
918c2ecf20Sopenharmony_ci#define orion5x_setbits(r, mask)	writel(readl(r) | (mask), (r))
928c2ecf20Sopenharmony_ci#define orion5x_clrbits(r, mask)	writel(readl(r) & ~(mask), (r))
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#endif
95