-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: microchip_pit: add driver for sama7g54's pit64b
Add support for the peripheral PIT64B in sama7g54. In the driver the clocks are initialized for PIT64B. Signed-off-by: Tony Han <[email protected]>
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
/* | ||
* Copyright (c) 2024, Microchip | ||
*/ | ||
|
||
#include <assert.h> | ||
#include <drivers/clk.h> | ||
#include <drivers/clk_dt.h> | ||
#include <dt_driver.h> | ||
#include <string.h> | ||
|
||
#define MCHP_PIT64B_FREQ UL(5000000) /* 5 MHz */ | ||
|
||
static TEE_Result microchip_pit_probe(const void *fdt, int node, | ||
const void *compat_data __unused) | ||
{ | ||
TEE_Result res = TEE_ERROR_GENERIC; | ||
struct clk *parent = NULL; | ||
struct clk *pclk = NULL; | ||
struct clk *gclk = NULL; | ||
size_t i = 0; | ||
|
||
res = clk_dt_get_by_name(fdt, node, "pclk", &pclk); | ||
if (res) | ||
return res; | ||
|
||
res = clk_dt_get_by_name(fdt, node, "gclk", &gclk); | ||
if (res) | ||
return res; | ||
|
||
res = clk_enable(pclk); | ||
if (res) | ||
panic(); | ||
|
||
do { | ||
parent = clk_get_parent_by_index(gclk, i++); | ||
if (!memcmp("syspll", clk_get_name(parent), sizeof("syspll"))) | ||
break; | ||
} while (parent); | ||
if (!parent) | ||
panic(); | ||
|
||
res = clk_set_parent(gclk, parent); | ||
if (res) | ||
panic(); | ||
|
||
res = clk_set_rate(gclk, MCHP_PIT64B_FREQ); | ||
if (res) | ||
panic(); | ||
|
||
return clk_enable(gclk); | ||
} | ||
|
||
static const struct dt_device_match microchip_pit_match_table[] = { | ||
{ .compatible = "microchip,sama7g5-pit64b" }, | ||
{ } | ||
}; | ||
|
||
DEFINE_DT_DRIVER(microchip_pit_dt_driver) = { | ||
.name = "microchip_pit", | ||
.type = DT_DRIVER_NOTYPE, | ||
.match_table = microchip_pit_match_table, | ||
.probe = microchip_pit_probe, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters