|
1 | 1 | /* |
2 | 2 | * Copyright (c) 2017 Piotr Mienkowski |
3 | | - * Copyright (c) 2020 Gerson Fernando Budke <[email protected]> |
| 3 | + * Copyright (c) 2020-2023 Gerson Fernando Budke <[email protected]> |
4 | 4 | * |
5 | 5 | * SPDX-License-Identifier: Apache-2.0 |
6 | 6 | */ |
|
23 | 23 | #include <soc.h> |
24 | 24 | #include <zephyr/drivers/i2c.h> |
25 | 25 | #include <zephyr/drivers/pinctrl.h> |
| 26 | +#include <zephyr/drivers/clock_control/atmel_sam_pmc.h> |
26 | 27 |
|
27 | 28 | #define LOG_LEVEL CONFIG_I2C_LOG_LEVEL |
28 | 29 | #include <zephyr/logging/log.h> |
@@ -66,8 +67,8 @@ struct i2c_sam_twim_dev_cfg { |
66 | 67 | Twim *regs; |
67 | 68 | void (*irq_config)(void); |
68 | 69 | uint32_t bitrate; |
| 70 | + const struct atmel_sam_pmc_config clock_cfg; |
69 | 71 | const struct pinctrl_dev_config *pcfg; |
70 | | - uint8_t periph_id; |
71 | 72 | uint8_t irq_id; |
72 | 73 |
|
73 | 74 | uint8_t std_clk_slew_lim; |
@@ -558,8 +559,9 @@ static int i2c_sam_twim_initialize(const struct device *dev) |
558 | 559 | return ret; |
559 | 560 | } |
560 | 561 |
|
561 | | - /* Enable module's clock */ |
562 | | - soc_pmc_peripheral_enable(cfg->periph_id); |
| 562 | + /* Enable TWIM clock in PM */ |
| 563 | + (void)clock_control_on(SAM_DT_PMC_CONTROLLER, |
| 564 | + (clock_control_subsys_t *)&cfg->clock_cfg); |
563 | 565 |
|
564 | 566 | /* Enable the module*/ |
565 | 567 | twim->CR = TWIM_CR_MEN; |
@@ -614,7 +616,7 @@ static const struct i2c_driver_api i2c_sam_twim_driver_api = { |
614 | 616 | static const struct i2c_sam_twim_dev_cfg i2c##n##_sam_config = {\ |
615 | 617 | .regs = (Twim *)DT_INST_REG_ADDR(n), \ |
616 | 618 | .irq_config = i2c##n##_sam_irq_config, \ |
617 | | - .periph_id = DT_INST_PROP(n, peripheral_id), \ |
| 619 | + .clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(n), \ |
618 | 620 | .irq_id = DT_INST_IRQN(n), \ |
619 | 621 | .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \ |
620 | 622 | .bitrate = DT_INST_PROP(n, clock_frequency), \ |
|
0 commit comments