drivers: can: sam: Update to use clock control
This update Atmel SAM can driver to use clock control driver. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
parent
4f59d50441
commit
41ab680a4f
3 changed files with 9 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <zephyr/drivers/can.h>
|
#include <zephyr/drivers/can.h>
|
||||||
#include <zephyr/drivers/pinctrl.h>
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
|
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
|
@ -20,8 +21,8 @@ LOG_MODULE_REGISTER(can_sam, CONFIG_CAN_LOG_LEVEL);
|
||||||
|
|
||||||
struct can_sam_config {
|
struct can_sam_config {
|
||||||
void (*config_irq)(void);
|
void (*config_irq)(void);
|
||||||
|
const struct atmel_sam_pmc_config clock_cfg;
|
||||||
const struct pinctrl_dev_config *pcfg;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
uint8_t pmc_id;
|
|
||||||
int divider;
|
int divider;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,7 +45,9 @@ static void can_sam_clock_enable(const struct can_sam_config *sam_cfg)
|
||||||
REG_PMC_PCK5 = PMC_PCK_CSS_UPLL_CLK | PMC_PCK_PRES(sam_cfg->divider - 1);
|
REG_PMC_PCK5 = PMC_PCK_CSS_UPLL_CLK | PMC_PCK_PRES(sam_cfg->divider - 1);
|
||||||
PMC->PMC_SCER |= PMC_SCER_PCK5;
|
PMC->PMC_SCER |= PMC_SCER_PCK5;
|
||||||
|
|
||||||
soc_pmc_peripheral_enable(sam_cfg->pmc_id);
|
/* Enable CAN clock in PMC */
|
||||||
|
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
|
||||||
|
(clock_control_subsys_t *)&sam_cfg->clock_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int can_sam_init(const struct device *dev)
|
static int can_sam_init(const struct device *dev)
|
||||||
|
@ -136,7 +139,7 @@ static void config_can_##inst##_irq(void)
|
||||||
|
|
||||||
#define CAN_SAM_CFG_INST(inst) \
|
#define CAN_SAM_CFG_INST(inst) \
|
||||||
static const struct can_sam_config can_sam_cfg_##inst = { \
|
static const struct can_sam_config can_sam_cfg_##inst = { \
|
||||||
.pmc_id = DT_INST_PROP(inst, peripheral_id), \
|
.clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(inst), \
|
||||||
.divider = DT_INST_PROP(inst, divider), \
|
.divider = DT_INST_PROP(inst, divider), \
|
||||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
|
||||||
.config_irq = config_can_##inst##_irq, \
|
.config_irq = config_can_##inst##_irq, \
|
||||||
|
|
|
@ -424,7 +424,7 @@
|
||||||
reg-names = "m_can";
|
reg-names = "m_can";
|
||||||
interrupts = <35 0>, <36 0>;
|
interrupts = <35 0>, <36 0>;
|
||||||
interrupt-names = "LINE_0", "LINE_1";
|
interrupt-names = "LINE_0", "LINE_1";
|
||||||
peripheral-id = <35>;
|
clocks = <&pmc PMC_TYPE_PERIPHERAL 35>;
|
||||||
divider = <6>;
|
divider = <6>;
|
||||||
sjw = <1>;
|
sjw = <1>;
|
||||||
sample-point = <875>;
|
sample-point = <875>;
|
||||||
|
@ -439,7 +439,7 @@
|
||||||
reg-names = "m_can";
|
reg-names = "m_can";
|
||||||
interrupts = <37 0>, <38 0>;
|
interrupts = <37 0>, <38 0>;
|
||||||
interrupt-names = "LINE_0", "LINE_1";
|
interrupt-names = "LINE_0", "LINE_1";
|
||||||
peripheral-id = <37>;
|
clocks = <&pmc PMC_TYPE_PERIPHERAL 37>;
|
||||||
divider = <6>;
|
divider = <6>;
|
||||||
sjw = <1>;
|
sjw = <1>;
|
||||||
sample-point = <875>;
|
sample-point = <875>;
|
||||||
|
|
|
@ -13,10 +13,8 @@ properties:
|
||||||
interrupts:
|
interrupts:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
peripheral-id:
|
clocks:
|
||||||
type: int
|
|
||||||
required: true
|
required: true
|
||||||
description: peripheral ID
|
|
||||||
|
|
||||||
divider:
|
divider:
|
||||||
type: int
|
type: int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue