Skip to content

Commit 3c7988c

Browse files
nandojvembolivar-nordic
authored andcommitted
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 <[email protected]>
1 parent c77c1cc commit 3c7988c

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

drivers/ethernet/eth_sam_gmac.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*
22
* Copyright (c) 2016 Piotr Mienkowski
33
* Copyright (c) 2018 Antmicro Ltd
4+
* Copyright (c) 2023 Gerson Fernando Budke
45
*
56
* SPDX-License-Identifier: Apache-2.0
67
*/
@@ -43,6 +44,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
4344
#include <ethernet/eth_stats.h>
4445
#include <zephyr/drivers/i2c.h>
4546
#include <zephyr/drivers/pinctrl.h>
47+
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
4648
#include <soc.h>
4749
#include "eth_sam_gmac_priv.h"
4850

@@ -1776,8 +1778,8 @@ static int eth_initialize(const struct device *dev)
17761778

17771779
#ifdef CONFIG_SOC_FAMILY_SAM
17781780
/* Enable GMAC module's clock */
1779-
soc_pmc_peripheral_enable(cfg->periph_id);
1780-
1781+
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
1782+
(clock_control_subsys_t *)&cfg->clock_cfg);
17811783
#else
17821784
/* Enable MCLK clock on GMAC */
17831785
MCLK->AHBMASK.reg |= MCLK_AHBMASK_GMAC;
@@ -2212,7 +2214,7 @@ static const struct eth_sam_dev_cfg eth0_config = {
22122214
.regs = (Gmac *)DT_INST_REG_ADDR(0),
22132215
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
22142216
#ifdef CONFIG_SOC_FAMILY_SAM
2215-
.periph_id = DT_INST_PROP_OR(0, peripheral_id, 0),
2217+
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0),
22162218
#endif
22172219
.config_func = eth0_irq_config,
22182220
#if DT_NODE_EXISTS(DT_INST_CHILD(0, phy))

drivers/ethernet/eth_sam_gmac_priv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ struct gmac_queue {
261261
/* Device constant configuration parameters */
262262
struct eth_sam_dev_cfg {
263263
Gmac *regs;
264-
const struct pinctrl_dev_config *pcfg;
265264
#ifdef CONFIG_SOC_FAMILY_SAM
266-
uint32_t periph_id;
265+
const struct atmel_sam_pmc_config clock_cfg;
267266
#endif
267+
const struct pinctrl_dev_config *pcfg;
268268
void (*config_func)(void);
269269
const struct device *phy_dev;
270270
};

dts/arm/atmel/sam4e.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
gmac: ethernet@40034000 {
142142
compatible = "atmel,sam-gmac";
143143
reg = <0x40034000 0x4000>;
144-
peripheral-id = <44>;
144+
clocks = <&pmc PMC_TYPE_PERIPHERAL 44>;
145145
interrupts = <44 0>;
146146
interrupt-names = "gmac";
147147
num-queues = <1>;

dts/arm/atmel/same70.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
gmac: ethernet@40050000 {
322322
compatible = "atmel,sam-gmac";
323323
reg = <0x40050000 0x4000>;
324-
peripheral-id = <39>;
324+
clocks = <&pmc PMC_TYPE_PERIPHERAL 39>;
325325
interrupts = <39 0>, <66 0>, <67 0>;
326326
interrupt-names = "gmac", "q1", "q2";
327327
num-queues = <3>;
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2021 Gerson Fernando Budke <[email protected]>
1+
# Copyright (c) 2021-2023 Gerson Fernando Budke <[email protected]>
22
# SPDX-License-Identifier: Apache-2.0
33

44
description: Atmel SAM-family GMAC Ethernet
@@ -8,11 +8,5 @@ compatible: "atmel,sam-gmac"
88
include: atmel,gmac-common.yaml
99

1010
properties:
11-
peripheral-id:
12-
type: int
11+
clocks:
1312
required: true
14-
description: |
15-
The peripheral identifier is required for Atmel SAMs MCUs to indicate
16-
which is the clock line associated with a specific peripheral. This
17-
clock line is defined at Power Management Controller (PMC) and it
18-
enables the peripheral.

0 commit comments

Comments
 (0)