public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Purna Chandra Mandal <purna.mandal@microchip.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 03/14] drivers: clk: Add clock driver for Microchip PIC32 Microcontroller.
Date: Thu, 14 Jan 2016 11:04:17 +0530	[thread overview]
Message-ID: <56973359.4020805@microchip.com> (raw)
In-Reply-To: <1452692304.3931.5.camel@gmail.com>

On 01/13/2016 07:08 PM, Daniel Schwierzeck wrote:

> Am Dienstag, den 12.01.2016, 15:48 +0530 schrieb Purna Chandra Mandal:
>> PIC32 clock module consists of multiple oscillators, PLLs,
>> mutiplexers
>> and dividers capable of supplying clock to various controllers
>> on or off-chip.
>>
>> Signed-off-by: Purna Chandra Mandal <purna.mandal@microchip.com>
>> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
>
> nits below
>
>> ---
>>
>> Changes in v3:
>> - rename clk-pic32.c to clk_pic32.c
>> - update clock binding documentation
>> - replace pic32_ioremap() with ioremap()
>> - separate MPLL initialization constants
>>
>> Changes in v2:
>> - add mpll get clock rate
>>
>>  .../clock/microchip,pic32-clock.txt                |  33 ++
>>  drivers/clk/Makefile                               |   1 +
>>  drivers/clk/clk_pic32.c                            | 433
>> +++++++++++++++++++++
>>  include/dt-bindings/clock/microchip,clock.h        |  29 ++
>>  4 files changed, 496 insertions(+)
>>  create mode 100644 doc/device-tree-bindings/clock/microchip,pic32
>> -clock.txt
>>  create mode 100644 drivers/clk/clk_pic32.c
>>  create mode 100644 include/dt-bindings/clock/microchip,clock.h
>>
>> diff --git a/doc/device-tree-bindings/clock/microchip,pic32-clock.txt
>> b/doc/device-tree-bindings/clock/microchip,pic32-clock.txt
>> new file mode 100644
>> index 0000000..02e5ce4
>> --- /dev/null
>> +++ b/doc/device-tree-bindings/clock/microchip,pic32-clock.txt
>> @@ -0,0 +1,33 @@
>> +* Microchip PIC32 Clock and Oscillator
>> +
>> +Microchip PIC32 clock tree consists of few oscillators, PLLs,
>> +multiplexers and few divider modules capable of supplying clocks
>> +to various controllers within SoC and also to off-chip.
>> +
>> +PIC32 clock controller output is defined by indices as defined
>> +in [0]
>> +
>> +[0] include/dt-bindings/clock/microchip,clock.h
>> +
>> +Required Properties:
>> +- compatible: should be "microchip,pic32mzda_clk"
>> +- reg: physical base address of the controller and length of memory
>> mapped
>> +       region.
>> +- #clock-cells: should be 1.
>> +
>> +Example: Clock controller node:
>> +
>> +	clock: clk at 1f801200 {
>> +		compatible = "microchip,pic32mzda_clk";
>> +		reg = <0x1f801200 0x1000>;
>> +	};
>> +
>> +Example: UART controller node that consumes the clock generated by
>> the clock
>> +controller:
>> +
>> +	uart1: serial at 1f822000 {
>> +		compatible = "microchip,pic32mzda-uart";
>> +		reg = <0xbf822000 0x50>;
>> +		interrupts = <112 IRQ_TYPE_LEVEL_HIGH>;
>> +		clocks = <&clock PB2CLK>;
>> +	};
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 4a6a4a8..adda769 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -9,3 +9,4 @@ obj-$(CONFIG_CLK) += clk-uclass.o
>>  obj-$(CONFIG_ROCKCHIP_RK3036) += clk_rk3036.o
>>  obj-$(CONFIG_ROCKCHIP_RK3288) += clk_rk3288.o
>>  obj-$(CONFIG_SANDBOX) += clk_sandbox.o
>> +obj-$(CONFIG_MACH_PIC32) += clk_pic32.o
>> diff --git a/drivers/clk/clk_pic32.c b/drivers/clk/clk_pic32.c
>> new file mode 100644
>> index 0000000..bb0a1cf
>> --- /dev/null
>> +++ b/drivers/clk/clk_pic32.c
>> @@ -0,0 +1,433 @@
>> +/*
>> + * Copyright (C) 2015 Purna Chandra Mandal <
>> purna.mandal at microchip.com>
>> + *
>> + * SPDX-License-Identifier:	GPL-2.0+
>> + *
>> + */
>> +
>> [...]
>> +
>> +static ulong pic32_set_periph_rate(struct udevice *dev, int periph,
>> ulong rate)
>> +{
>> +	struct pic32_clk_priv *priv = dev_get_priv(dev);
>> +	ulong pll_hz;
>> +
>> +	switch (periph) {
>> +	case REF1CLK ... REF5CLK:
>> +		pll_hz = pic32_get_pll_rate(priv);
>> +		pic32_set_refclk(priv, periph, pll_hz, rate,
>> ROCLK_SRC_SPLL);
>> +		break;
>> +	default:
>> +		break;
>> +	}
>> +
>> +	return rate;
>> +}
>> +
>> +static struct clk_ops pic32_pic32_clk_ops = {
>> +	.get_rate = pic32_clk_get_rate,
>> +	.set_periph_rate = pic32_set_periph_rate,
>> +	.get_periph_rate = pic32_get_periph_rate,
>> +};
>> +
>> +static int pic32_clk_probe(struct udevice *dev)
>> +{
>> +	struct pic32_clk_priv *priv = dev_get_priv(dev);
>> +	fdt_addr_t addr;
>> +	fdt_size_t size;
>> +
>> +	addr = fdtdec_get_addr_size(gd->fdt_blob, dev->of_offset,
>> "reg", &size);
>> +	if (addr == FDT_ADDR_T_NONE)
>> +		return -EINVAL;
>> +
>> +	priv->iobase = ioremap(addr, size);
>> +	if (!priv->iobase)
>> +		return -EINVAL;
> you can drop this check. ioremap() always returns a mapped address

ack. Will drop.

>> +
>> +	priv->syscfg_base = pic32_get_syscfg_base();
>> +
>> +	/* initialize clocks */
>> +	pic32_clk_init(dev);
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct udevice_id pic32_clk_ids[] = {
>> +	{ .compatible = "microchip,pic32mzda_clk"},
>> +	{}
>> +};
>> +
>> +U_BOOT_DRIVER(pic32_clk) = {
>> +	.name		= "pic32_clk",
>> +	.id		= UCLASS_CLK,
>> +	.of_match	= pic32_clk_ids,
>> +	.flags		= DM_FLAG_PRE_RELOC,
>> +	.ops		= &pic32_pic32_clk_ops,
>> +	.probe		= pic32_clk_probe,
>> +	.priv_auto_alloc_size = sizeof(struct pic32_clk_priv),
>> +};
>> diff --git a/include/dt-bindings/clock/microchip,clock.h b/include/dt
>> -bindings/clock/microchip,clock.h
>> new file mode 100644
>> index 0000000..93c222d
>> --- /dev/null
>> +++ b/include/dt-bindings/clock/microchip,clock.h
>> @@ -0,0 +1,29 @@
>> +/*
>> + * (c) 2015 Purna Chandra Mandal <purna.mandal@microchip.com>
>> + *
>> + * SPDX-License-Identifier:	GPL-2.0+
>> + *
>> + */
>> +
>> +#ifndef __CLK_MICROCHIP_PIC32
>> +#define __CLK_MICROCHIP_PIC32
>> +
>> +/* clock output indices */
>> +#define BASECLK	0
>> +#define PLLCLK	1
>> +#define MPLL	2
>> +#define SYSCLK	3
>> +#define PB1CLK	4
>> +#define PB2CLK	5
>> +#define PB3CLK	6
>> +#define PB4CLK	7
>> +#define PB5CLK	8
>> +#define PB6CLK	9
>> +#define PB7CLK	10
>> +#define REF1CLK	11
>> +#define REF2CLK	12
>> +#define REF3CLK	13
>> +#define REF4CLK	14
>> +#define REF5CLK	15
>> +
>> +#endif	/* __CLK_MICROCHIP_PIC32 */

  reply	other threads:[~2016-01-14  5:34 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12 10:18 [U-Boot] [PATCH v3 00/14] Initial Microchip PIC32MZ[DA] Support Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 01/14] MIPS: initialize board_init_f() argument to zero Purna Chandra Mandal
2016-01-12 12:29   ` Daniel Schwierzeck
2016-01-14  5:29     ` Purna Chandra Mandal
2016-01-21 14:06       ` Daniel Schwierzeck
2016-01-12 10:18 ` [U-Boot] [PATCH v3 02/14] MIPS: initial infrastructure for Microchip PIC32 architecture Purna Chandra Mandal
2016-01-12 12:55   ` Daniel Schwierzeck
2016-01-13 14:56   ` Tom Rini
2016-01-12 10:18 ` [U-Boot] [PATCH v3 03/14] drivers: clk: Add clock driver for Microchip PIC32 Microcontroller Purna Chandra Mandal
2016-01-13 13:38   ` Daniel Schwierzeck
2016-01-14  5:34     ` Purna Chandra Mandal [this message]
2016-01-13 14:55   ` Tom Rini
2016-01-14  6:04     ` Purna Chandra Mandal
2016-01-14 12:30       ` Tom Rini
2016-01-12 10:18 ` [U-Boot] [PATCH v3 04/14] drivers: pinctrl: Add pinctrl driver for Microchip PIC32 Purna Chandra Mandal
2016-01-13 13:42   ` Daniel Schwierzeck
2016-01-13 14:55   ` Tom Rini
2016-01-13 20:10   ` Simon Glass
2016-01-12 10:18 ` [U-Boot] [PATCH v3 05/14] drivers: gpio: add driver for Microchip PIC32 GPIO controller Purna Chandra Mandal
2016-01-13 13:46   ` Daniel Schwierzeck
2016-01-13 14:08     ` Daniel Schwierzeck
2016-01-14  5:41       ` Purna Chandra Mandal
2016-01-13 14:55   ` Tom Rini
2016-01-13 20:10   ` Simon Glass
2016-01-14 10:15     ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 06/14] drivers: serial: add driver for Microchip PIC32 UART controller Purna Chandra Mandal
2016-01-13 13:49   ` Daniel Schwierzeck
2016-01-13 14:03     ` Daniel Schwierzeck
2016-01-14  5:42       ` Purna Chandra Mandal
2016-01-13 14:55   ` Tom Rini
2016-01-13 20:09   ` Simon Glass
2016-01-14  6:14     ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 07/14] drivers: ddr: Add DDR2 SDRAM controller driver for Microchip PIC32 Purna Chandra Mandal
2016-01-13 13:53   ` Daniel Schwierzeck
2016-01-13 14:55   ` Tom Rini
2016-01-13 20:09   ` Simon Glass
2016-01-12 10:18 ` [U-Boot] [PATCH v3 08/14] MIPS: Add support for Microchip PIC32MZ[DA] SoC family Purna Chandra Mandal
2016-01-13 14:49   ` Daniel Schwierzeck
2016-01-14  5:54     ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 09/14] board: Add Microchip PIC32MZ[DA]-Starter-Kit board Purna Chandra Mandal
2016-01-13 14:56   ` Tom Rini
2016-01-14  6:40     ` Purna Chandra Mandal
2016-01-13 15:03   ` Daniel Schwierzeck
2016-01-14  8:40     ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 10/14] drivers: mmc: add driver for Microchip PIC32 SDHCI controller Purna Chandra Mandal
2016-01-13 14:56   ` Tom Rini
2016-01-13 15:15   ` Daniel Schwierzeck
2016-01-14  9:18     ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 11/14] board: add SDHCI support for PIC32MZDASK board Purna Chandra Mandal
2016-01-13 14:56   ` Tom Rini
2016-01-14  8:31     ` Purna Chandra Mandal
2016-01-12 10:18 ` [U-Boot] [PATCH v3 12/14] drivers: net: phy: add SMSC LAN8740 Phy support Purna Chandra Mandal
2016-01-13 14:56   ` Tom Rini
2016-01-13 15:19   ` Daniel Schwierzeck
2016-01-12 10:18 ` [U-Boot] [PATCH v3 13/14] drivers: net: Add ethernet driver for Microchip PIC32 Purna Chandra Mandal
2016-01-13 14:56   ` Tom Rini
2016-01-14 10:29     ` Purna Chandra Mandal
2016-01-13 15:37   ` Daniel Schwierzeck
2016-01-14 10:05     ` Purna Chandra Mandal
2016-01-14 14:01       ` Daniel Schwierzeck
2016-01-12 10:18 ` [U-Boot] [PATCH v3 14/14] board: Enable ethernet, tftpboot support to pic32mzdask board Purna Chandra Mandal
2016-01-13 14:56   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56973359.4020805@microchip.com \
    --to=purna.mandal@microchip.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox