drivers: usb: sam: Update to use clock control
This update Atmel SAM usbhs driver to use clock control driver. Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
parent
033c7eddec
commit
5522e65581
|
@ -7,6 +7,7 @@
|
||||||
#define DT_DRV_COMPAT atmel_sam_usbhs
|
#define DT_DRV_COMPAT atmel_sam_usbhs
|
||||||
|
|
||||||
#include <zephyr/usb/usb_device.h>
|
#include <zephyr/usb/usb_device.h>
|
||||||
|
#include <zephyr/drivers/clock_control/atmel_sam_pmc.h>
|
||||||
#include <zephyr/irq.h>
|
#include <zephyr/irq.h>
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
@ -309,10 +310,12 @@ static void usb_dc_isr(void)
|
||||||
/* Attach USB for device connection */
|
/* Attach USB for device connection */
|
||||||
int usb_dc_attach(void)
|
int usb_dc_attach(void)
|
||||||
{
|
{
|
||||||
|
const struct atmel_sam_pmc_config clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0);
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
|
|
||||||
/* Start the peripheral clock */
|
/* Enable USBHS clock in PMC */
|
||||||
soc_pmc_peripheral_enable(DT_INST_PROP(0, peripheral_id));
|
(void)clock_control_on(SAM_DT_PMC_CONTROLLER,
|
||||||
|
(clock_control_subsys_t *)&clock_cfg);
|
||||||
|
|
||||||
/* Enable the USB controller in device mode with the clock frozen */
|
/* Enable the USB controller in device mode with the clock frozen */
|
||||||
USBHS->USBHS_CTRL = USBHS_CTRL_UIMOD | USBHS_CTRL_USBE |
|
USBHS->USBHS_CTRL = USBHS_CTRL_UIMOD | USBHS_CTRL_USBE |
|
||||||
|
@ -359,6 +362,8 @@ int usb_dc_attach(void)
|
||||||
/* Detach the USB device */
|
/* Detach the USB device */
|
||||||
int usb_dc_detach(void)
|
int usb_dc_detach(void)
|
||||||
{
|
{
|
||||||
|
const struct atmel_sam_pmc_config clock_cfg = SAM_DT_INST_CLOCK_PMC_CFG(0);
|
||||||
|
|
||||||
/* Detach the device */
|
/* Detach the device */
|
||||||
USBHS->USBHS_DEVCTRL |= USBHS_DEVCTRL_DETACH;
|
USBHS->USBHS_DEVCTRL |= USBHS_DEVCTRL_DETACH;
|
||||||
|
|
||||||
|
@ -368,8 +373,9 @@ int usb_dc_detach(void)
|
||||||
/* Disable the USB controller and freeze the clock */
|
/* Disable the USB controller and freeze the clock */
|
||||||
USBHS->USBHS_CTRL = USBHS_CTRL_UIMOD | USBHS_CTRL_FRZCLK;
|
USBHS->USBHS_CTRL = USBHS_CTRL_UIMOD | USBHS_CTRL_FRZCLK;
|
||||||
|
|
||||||
/* Disable the peripheral clock */
|
/* Disable USBHS clock in PMC */
|
||||||
soc_pmc_peripheral_enable(DT_INST_PROP(0, peripheral_id));
|
(void)clock_control_off(SAM_DT_PMC_CONTROLLER,
|
||||||
|
(clock_control_subsys_t *)&clock_cfg);
|
||||||
|
|
||||||
/* Disable interrupt */
|
/* Disable interrupt */
|
||||||
irq_disable(DT_INST_IRQN(0));
|
irq_disable(DT_INST_IRQN(0));
|
||||||
|
|
|
@ -166,7 +166,7 @@
|
||||||
interrupt-names = "usbc";
|
interrupt-names = "usbc";
|
||||||
maximum-speed = "full-speed";
|
maximum-speed = "full-speed";
|
||||||
num-bidir-endpoints = <8>;
|
num-bidir-endpoints = <8>;
|
||||||
peripheral-id = <101>;
|
clocks = <&pmc PMC_TYPE_PERIPHERAL 101>;
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -314,7 +314,7 @@
|
||||||
interrupt-names = "usbhs";
|
interrupt-names = "usbhs";
|
||||||
maximum-speed = "high-speed";
|
maximum-speed = "high-speed";
|
||||||
num-bidir-endpoints = <10>;
|
num-bidir-endpoints = <10>;
|
||||||
peripheral-id = <34>;
|
clocks = <&pmc PMC_TYPE_PERIPHERAL 34>;
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Copyright (c) 2018 Aurelien Jarno
|
# Copyright (c) 2018 Aurelien Jarno
|
||||||
# Copyright (c) 2020 Gerson Fernando Budke <nandojve@gmail.com>
|
# Copyright (c) 2020*2023 Gerson Fernando Budke <nandojve@gmail.com>
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
description: |
|
description: |
|
||||||
|
@ -18,7 +18,5 @@ properties:
|
||||||
interrupts:
|
interrupts:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
peripheral-id:
|
clocks:
|
||||||
type: int
|
|
||||||
required: true
|
required: true
|
||||||
description: peripheral ID
|
|
||||||
|
|
|
@ -17,7 +17,5 @@ properties:
|
||||||
interrupts:
|
interrupts:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
peripheral-id:
|
clocks:
|
||||||
type: int
|
|
||||||
required: true
|
required: true
|
||||||
description: peripheral ID
|
|
||||||
|
|
Loading…
Reference in a new issue