drivers: eth: sam: Update to use clock control

This update Atmel SAM ethernet driver to use clock control drivers.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
Gerson Fernando Budke 2023-03-05 23:16:18 +01:00 committed by Marti Bolivar
parent c77c1cc197
commit 3c7988c52a
5 changed files with 11 additions and 15 deletions

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2016 Piotr Mienkowski
* Copyright (c) 2018 Antmicro Ltd
* Copyright (c) 2023 Gerson Fernando Budke
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -43,6 +44,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <ethernet/eth_stats.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
#include <soc.h>
#include "eth_sam_gmac_priv.h"
@ -1776,8 +1778,8 @@ static int eth_initialize(const struct device *dev)
#ifdef CONFIG_SOC_FAMILY_SAM
/* Enable GMAC module's clock */
soc_pmc_peripheral_enable(cfg->periph_id);
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
(clock_control_subsys_t *)&cfg->clock_cfg);
#else
/* Enable MCLK clock on GMAC */
MCLK->AHBMASK.reg |= MCLK_AHBMASK_GMAC;
@ -2212,7 +2214,7 @@ static const struct eth_sam_dev_cfg eth0_config = {
.regs = (Gmac *)DT_INST_REG_ADDR(0),
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
#ifdef CONFIG_SOC_FAMILY_SAM
.periph_id = DT_INST_PROP_OR(0, peripheral_id, 0),
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0),
#endif
.config_func = eth0_irq_config,
#if DT_NODE_EXISTS(DT_INST_CHILD(0, phy))

View file

@ -261,10 +261,10 @@ struct gmac_queue {
/* Device constant configuration parameters */
struct eth_sam_dev_cfg {
Gmac *regs;
const struct pinctrl_dev_config *pcfg;
#ifdef CONFIG_SOC_FAMILY_SAM
uint32_t periph_id;
const struct atmel_sam_pmc_config clock_cfg;
#endif
const struct pinctrl_dev_config *pcfg;
void (*config_func)(void);
const struct device *phy_dev;
};

View file

@ -141,7 +141,7 @@
gmac: ethernet@40034000 {
compatible = "atmel,sam-gmac";
reg = <0x40034000 0x4000>;
peripheral-id = <44>;
clocks = <&pmc PMC_TYPE_PERIPHERAL 44>;
interrupts = <44 0>;
interrupt-names = "gmac";
num-queues = <1>;

View file

@ -321,7 +321,7 @@
gmac: ethernet@40050000 {
compatible = "atmel,sam-gmac";
reg = <0x40050000 0x4000>;
peripheral-id = <39>;
clocks = <&pmc PMC_TYPE_PERIPHERAL 39>;
interrupts = <39 0>, <66 0>, <67 0>;
interrupt-names = "gmac", "q1", "q2";
num-queues = <3>;

View file

@ -1,4 +1,4 @@
# Copyright (c) 2021 Gerson Fernando Budke <nandojve@gmail.com>
# Copyright (c) 2021-2023 Gerson Fernando Budke <nandojve@gmail.com>
# SPDX-License-Identifier: Apache-2.0
description: Atmel SAM-family GMAC Ethernet
@ -8,11 +8,5 @@ compatible: "atmel,sam-gmac"
include: atmel,gmac-common.yaml
properties:
peripheral-id:
type: int
clocks:
required: true
description: |
The peripheral identifier is required for Atmel SAMs MCUs to indicate
which is the clock line associated with a specific peripheral. This
clock line is defined at Power Management Controller (PMC) and it
enables the peripheral.