1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2015-2016 Marvell International Ltd.
6 #ifndef _COMPHY_CORE_H_
7 #define _COMPHY_CORE_H_
10 #include <mvebu/comphy.h>
13 #define debug_enter() printf("----> Enter %s\n", __func__);
14 #define debug_exit() printf("<---- Exit %s\n", __func__);
20 #define MAX_LANE_OPTIONS 10
21 #define MAX_UTMI_PHY_COUNT 6
23 struct comphy_mux_options {
28 struct comphy_mux_data {
30 struct comphy_mux_options mux_values[MAX_LANE_OPTIONS];
33 struct chip_serdes_phy_config {
34 struct comphy_mux_data *mux_data;
35 int (*ptr_comphy_chip_init)(struct chip_serdes_phy_config *,
37 int (*rx_training)(struct chip_serdes_phy_config *, u32);
38 void __iomem *comphy_base_addr;
39 void __iomem *hpipe3_base_addr;
40 u32 comphy_lanes_count;
41 u32 comphy_mux_bitcount;
42 const fdt32_t *comphy_mux_lane_order;
44 struct comphy_map comphy_map_data[MAX_LANE_OPTIONS];
47 /* Register helper functions */
48 static inline void reg_set_silent(void __iomem *addr, u32 data, u32 mask)
52 reg_data = readl(addr);
55 writel(reg_data, addr);
58 static inline void reg_set(void __iomem *addr, u32 data, u32 mask)
60 debug("Write to address = %#010lx, data = %#010x (mask = %#010x) - ",
61 (unsigned long)addr, data, mask);
62 debug("old value = %#010x ==> ", readl(addr));
63 reg_set_silent(addr, data, mask);
64 debug("new value %#010x\n", readl(addr));
67 static inline void reg_set_silent16(void __iomem *addr, u16 data, u16 mask)
71 reg_data = readw(addr);
74 writew(reg_data, addr);
77 static inline void reg_set16(void __iomem *addr, u16 data, u16 mask)
79 debug("Write to address = %#010lx, data = %#06x (mask = %#06x) - ",
80 (unsigned long)addr, data, mask);
81 debug("old value = %#06x ==> ", readw(addr));
82 reg_set_silent16(addr, data, mask);
83 debug("new value %#06x\n", readw(addr));
86 /* SoC specific init functions */
87 #ifdef CONFIG_ARMADA_3700
88 int comphy_a3700_init(struct chip_serdes_phy_config *ptr_chip_cfg,
89 struct comphy_map *serdes_map);
91 static inline int comphy_a3700_init(struct chip_serdes_phy_config *ptr_chip_cfg,
92 struct comphy_map *serdes_map)
95 * This function should never be called in this configuration, so
96 * lets return an error here.
102 #ifdef CONFIG_ARMADA_8K
103 int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg,
104 struct comphy_map *serdes_map);
105 int comphy_cp110_sfi_rx_training(struct chip_serdes_phy_config *ptr_chip_cfg,
108 static inline int comphy_cp110_init(struct chip_serdes_phy_config *ptr_chip_cfg,
109 struct comphy_map *serdes_map)
112 * This function should never be called in this configuration, so
113 * lets return an error here.
118 static inline int comphy_cp110_sfi_rx_training(
119 struct chip_serdes_phy_config *ptr_chip_cfg,
123 * This function should never be called in this configuration, so
124 * lets return an error here.
130 void comphy_dedicated_phys_init(void);
133 void comphy_mux_init(struct chip_serdes_phy_config *ptr_chip_cfg,
134 struct comphy_map *comphy_map_data,
135 void __iomem *selector_base);
137 void comphy_pcie_config_set(u32 comphy_max_count,
138 struct comphy_map *serdes_map);
139 void comphy_pcie_config_detect(u32 comphy_max_count,
140 struct comphy_map *serdes_map);
141 void comphy_pcie_unit_general_config(u32 pex_index);
143 #endif /* _COMPHY_CORE_H_ */