From: Stephen Boyd <sboyd@kernel.org>
To: Alexander Sverdlin <alexander.sverdlin@gmail.com>,
Conor Dooley <conor+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Michael Turquette <mturquette@baylibre.com>,
Nikita Shubin via B4 Relay
<devnull+nikita.shubin.maquefel.me@kernel.org>,
Rob Herring <robh@kernel.org>,
nikita.shubin@maquefel.me
Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
devicetree@vger.kernel.org,
Nikita Shubin <nikita.shubin@maquefel.me>,
Arnd Bergmann <arnd@arndb.de>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 4/4] soc: Add SoC driver for Cirrus ep93xx
Date: Thu, 11 Apr 2024 02:26:31 -0700 [thread overview]
Message-ID: <11055a03e605f9134f91af3e3f3a6c58.sboyd@kernel.org> (raw)
In-Reply-To: <20240408-ep93xx-clk-v1-4-1d0f4c324647@maquefel.me>
Quoting Nikita Shubin via B4 Relay (2024-04-08 01:09:56)
> diff --git a/drivers/soc/cirrus/soc-ep93xx.c b/drivers/soc/cirrus/soc-ep93xx.c
> new file mode 100644
> index 000000000000..044f17f9ba55
> --- /dev/null
> +++ b/drivers/soc/cirrus/soc-ep93xx.c
> @@ -0,0 +1,240 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * SoC driver for Cirrus EP93xx chips.
> + * Copyright (C) 2022 Nikita Shubin <nikita.shubin@maquefel.me>
> + *
> + * Based on a rewrite of arch/arm/mach-ep93xx/core.c
> + * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
> + * Copyright (C) 2007 Herbert Valerio Riedel <hvr@gnu.org>
> + *
> + * Thanks go to Michael Burian and Ray Lehtiniemi for their key
> + * role in the ep93xx Linux community.
> + */
> +
> +#include <linux/bits.h>
> +#include <linux/cleanup.h>
> +#include <linux/init.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/of.h>
> +#include <linux/of_fdt.h>
Are these of includes used?
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/slab.h>
> +#include <linux/spinlock.h>
> +#include <linux/sys_soc.h>
> +
> +#include <linux/soc/cirrus/ep93xx.h>
> +
> +#define EP93XX_SYSCON_DEVCFG 0x80
> +
> +#define EP93XX_SWLOCK_MAGICK 0xaa
> +#define EP93XX_SYSCON_SWLOCK 0xc0
> +#define EP93XX_SYSCON_SYSCFG 0x9c
> +#define EP93XX_SYSCON_SYSCFG_REV_MASK GENMASK(31, 28)
> +#define EP93XX_SYSCON_SYSCFG_REV_SHIFT 28
> +
[...]
> +
> +static void ep93xx_unregister_adev(void *_adev)
> +{
> + struct auxiliary_device *adev = _adev;
> +
> + auxiliary_device_delete(adev);
> + auxiliary_device_uninit(adev);
> +}
It really seems like auxiliary bus code should expose a
simple_unregister_adev() function that does this two line function once
instead of every driver repeating it.
> +
> +static void ep93xx_adev_release(struct device *dev)
> +{
> + struct auxiliary_device *adev = to_auxiliary_dev(dev);
> + struct ep93xx_regmap_adev *rdev = to_ep93xx_regmap_adev(adev);
> +
> + kfree(rdev);
> +}
> +
> +static struct auxiliary_device *ep93xx_adev_alloc(struct device *parent, const char *name,
__init?
> + struct ep93xx_map_info *info)
> +{
> + struct ep93xx_regmap_adev *rdev __free(kfree) = NULL;
> + struct auxiliary_device *adev;
> + int ret;
> +
> + rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
> + if (!rdev)
> + return ERR_PTR(-ENOMEM);
> +
> + rdev->map = info->map;
> + rdev->base = info->base;
> + rdev->lock = &info->lock;
> + rdev->write = ep93xx_regmap_write;
> + rdev->update_bits = ep93xx_regmap_update_bits;
> +
> + adev = &rdev->adev;
> + adev->name = name;
> + adev->dev.parent = parent;
> + adev->dev.release = ep93xx_adev_release;
> +
> + ret = auxiliary_device_init(adev);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + return &no_free_ptr(rdev)->adev;
> +}
> +
> +static int ep93xx_controller_register(struct device *parent, const char *name,
__init?
> + struct ep93xx_map_info *info)
> +{
> + struct auxiliary_device *adev;
> + int ret;
> +
> + adev = ep93xx_adev_alloc(parent, name, info);
> + if (IS_ERR(adev))
> + return PTR_ERR(adev);
> +
> + ret = auxiliary_device_add(adev);
> + if (ret) {
> + auxiliary_device_uninit(adev);
> + return ret;
> + }
> +
> + return devm_add_action_or_reset(parent, ep93xx_unregister_adev, adev);
> +}
> +
[...]
> +
> +static const char __init *ep93xx_get_soc_rev(struct regmap *map)
> +{
> + switch (ep93xx_soc_revision(map)) {
> + case EP93XX_CHIP_REV_D0:
> + return "D0";
> + case EP93XX_CHIP_REV_D1:
> + return "D1";
> + case EP93XX_CHIP_REV_E0:
> + return "E0";
> + case EP93XX_CHIP_REV_E1:
> + return "E1";
> + case EP93XX_CHIP_REV_E2:
> + return "E2";
> + default:
> + return "unknown";
> + }
> +}
> +
> +const char *pinctrl_names[] = {
static? Can also be __initconst? or moved into probe scope and placed on
the stack?
> + "pinctrl-ep9301", /* EP93XX_9301_SOC */
> + "pinctrl-ep9307", /* EP93XX_9307_SOC */
> + "pinctrl-ep9312", /* EP93XX_9312_SOC */
> +};
next prev parent reply other threads:[~2024-04-11 9:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-08 8:09 [PATCH 0/4] DONOTMERGE: ep93xx-clk from ep93xx device tree conversion Nikita Shubin via B4 Relay
2024-04-08 8:09 ` [PATCH 1/4] ARM: ep93xx: add regmap aux_dev Nikita Shubin via B4 Relay
2024-04-11 9:32 ` Stephen Boyd
2024-04-08 8:09 ` [PATCH 2/4] clk: ep93xx: add DT support for Cirrus EP93xx Nikita Shubin via B4 Relay
2024-04-11 9:32 ` Stephen Boyd
2024-04-14 9:35 ` Nikita Shubin
2024-04-08 8:09 ` [PATCH 3/4] dt-bindings: soc: Add " Nikita Shubin via B4 Relay
2024-04-11 9:21 ` Stephen Boyd
2024-04-08 8:09 ` [PATCH 4/4] soc: Add SoC driver for Cirrus ep93xx Nikita Shubin via B4 Relay
2024-04-11 9:26 ` Stephen Boyd [this message]
2024-04-08 17:03 ` [PATCH 0/4] DONOTMERGE: ep93xx-clk from ep93xx device tree conversion Conor Dooley
2024-04-09 11:48 ` Nikita Shubin
2024-04-09 15:09 ` Alexander Sverdlin
2024-04-09 17:32 ` Conor Dooley
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=11055a03e605f9134f91af3e3f3a6c58.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=alexander.sverdlin@gmail.com \
--cc=arnd@arndb.de \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+nikita.shubin.maquefel.me@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=nikita.shubin@maquefel.me \
--cc=robh@kernel.org \
/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