Lines Matching +full:divider +full:- +full:int +full:- +full:2
4 * SPDX-License-Identifier: Apache-2.0
41 uint32_t val = base->MAC_MDIO_ADDRESS; in check_busy()
47 static int do_transaction(struct mdio_transaction *mdio) in do_transaction()
49 enet_qos_t *base = mdio->base; in do_transaction()
51 int ret; in do_transaction()
53 k_mutex_lock(mdio->mdio_bus_mutex, K_FOREVER); in do_transaction()
55 if (mdio->op == MDIO_OP_C22_WRITE) { in do_transaction()
56 base->MAC_MDIO_DATA = in do_transaction()
58 ENET_QOS_REG_PREP(MAC_MDIO_DATA, GD, mdio->write_data); in do_transaction()
60 } else if (mdio->op == MDIO_OP_C22_READ) { in do_transaction()
63 ret = -EINVAL; in do_transaction()
67 base->MAC_MDIO_ADDRESS = in do_transaction()
72 ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, PA, mdio->portaddr) | in do_transaction()
74 ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, RDA, mdio->regaddr); in do_transaction()
76 base->MAC_MDIO_ADDRESS = in do_transaction()
81 ret = -ETIMEDOUT; in do_transaction()
82 for (int i = CONFIG_MDIO_NXP_ENET_QOS_RECHECK_COUNT; i > 0; i--) { in do_transaction()
95 if (mdio->op == MDIO_OP_C22_READ) { in do_transaction()
96 uint32_t val = mdio->base->MAC_MDIO_DATA; in do_transaction()
98 *mdio->read_data = in do_transaction()
104 k_mutex_unlock(mdio->mdio_bus_mutex); in do_transaction()
109 static int nxp_enet_qos_mdio_read(const struct device *dev, in nxp_enet_qos_mdio_read()
113 const struct nxp_enet_qos_mdio_config *config = dev->config; in nxp_enet_qos_mdio_read()
114 struct nxp_enet_qos_mdio_data *data = dev->data; in nxp_enet_qos_mdio_read()
115 enet_qos_t *base = ENET_QOS_MODULE_CFG(config->enet_dev)->base; in nxp_enet_qos_mdio_read()
122 .mdio_bus_mutex = &data->mdio_mutex, in nxp_enet_qos_mdio_read()
128 static int nxp_enet_qos_mdio_write(const struct device *dev, in nxp_enet_qos_mdio_write()
132 const struct nxp_enet_qos_mdio_config *config = dev->config; in nxp_enet_qos_mdio_write()
133 struct nxp_enet_qos_mdio_data *data = dev->data; in nxp_enet_qos_mdio_write()
134 enet_qos_t *base = ENET_QOS_MODULE_CFG(config->enet_dev)->base; in nxp_enet_qos_mdio_write()
141 .mdio_bus_mutex = &data->mdio_mutex, in nxp_enet_qos_mdio_write()
152 static int nxp_enet_qos_mdio_init(const struct device *dev) in nxp_enet_qos_mdio_init()
154 const struct nxp_enet_qos_mdio_config *mdio_config = dev->config; in nxp_enet_qos_mdio_init()
155 struct nxp_enet_qos_mdio_data *data = dev->data; in nxp_enet_qos_mdio_init()
156 const struct nxp_enet_qos_config *config = ENET_QOS_MODULE_CFG(mdio_config->enet_dev); in nxp_enet_qos_mdio_init()
158 int ret, divider; in nxp_enet_qos_mdio_init() local
160 ret = k_mutex_init(&data->mdio_mutex); in nxp_enet_qos_mdio_init()
165 ret = clock_control_get_rate(config->clock_dev, config->clock_subsys, in nxp_enet_qos_mdio_init()
173 divider = 2; in nxp_enet_qos_mdio_init()
175 divider = 3; in nxp_enet_qos_mdio_init()
177 divider = 0; in nxp_enet_qos_mdio_init()
179 divider = 1; in nxp_enet_qos_mdio_init()
181 divider = 4; in nxp_enet_qos_mdio_init()
184 return -ENOTSUP; in nxp_enet_qos_mdio_init()
187 config->base->MAC_MDIO_ADDRESS = in nxp_enet_qos_mdio_init()
188 /* Configure the MDIO clock range / divider */ in nxp_enet_qos_mdio_init()
189 ENET_QOS_REG_PREP(MAC_MDIO_ADDRESS, CR, divider); in nxp_enet_qos_mdio_init()