All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
To: kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] spi: bcm2835: add spi-bcm2835aux driver for the auxiliar spi1 and spi2
Date: Fri, 10 Jul 2015 22:53:36 -0600	[thread overview]
Message-ID: <55A0A150.3060809@wwwdotorg.org> (raw)
In-Reply-To: <1434980408-4086-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>

On 06/22/2015 07:40 AM, kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org wrote:
> From: Martin Sperl <kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
> 
> This driver does NOT make use of native chip-selects but uses the
> generic cs-gpios facilities provided by the framework allowing for
> more than 3 chip-selects.

> diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c

> +/*
> + * spi register defines
> + *
> + * note there is garbage in the "official" documentation,
> + * so somedata taken from the file:
> + *   brcm_usrlib/dag/vmcsx/vcinclude/bcm2708_chip/aux_io.h
> + * inside of:
> + *   http://www.broadcom.com/docs/support/videocore/Brcm_Android_ICS_Graphics_Stack.tar.gz
> + */

Hopefully the license of that tar file allows for that. I didn't look.

> +DEFINE_SPINLOCK(__bcm2835_aux_lock);
> +static void bcm2835_aux_modify_enable(struct bcm2835aux_spi *bs,
> +				      u32 mask, u32 val)
> +{
> +	unsigned long flags;
> +	u32 r;
> +
> +	spin_lock_irqsave(&__bcm2835_aux_lock, flags);
> +
> +	r = readl(bs->aux_regs + BCM2835_AUX_ENABLE);
> +	r &= mask;
> +	r |= val;
> +	writel(r, bs->aux_regs + BCM2835_AUX_ENABLE);
> +
> +	spin_unlock_irqrestore(&__bcm2835_aux_lock, flags);
> +}

As mentioned elsewhere, I'd hope all the shared aux register
manipulations can be pushed into a shared driver.

> +static void bcm2835aux_spi_enable(struct bcm2835aux_spi *bs)
> +{
> +	/* identify the spi device - needed to activate the right HW-block */
> +	u32 mask = (size_t)bs->regs & 0x00000040 ?
> +		   BCM2835_AUX_BIT_SPI2 : BCM2835_AUX_BIT_SPI1;
> +
> +	bcm2835_aux_modify_enable(bs, ~mask, mask);
> +}

I expect that function will go away when my previous comment is
resolved. If not, it'd be nice to encode the "ID" of the device into DT,
so that the driver has no hard-coded idea of what register addresses
exist; what happens when (a hypothetical) bcm2837 comes along with 3
instances of this HW block?

> +static int bcm2835aux_spi_remove(struct platform_device *pdev)
> +{
> +	struct spi_master *master = platform_get_drvdata(pdev);
> +	struct bcm2835aux_spi *bs = spi_master_get_devdata(master);
> +
> +	/* Clear FIFOs, and disable the HW block */
> +	clk_disable_unprepare(bs->clk);

You probably want remove() to do things in the reverse order of probe().
In particular, disable the clock after anything that could touch
registers in the HW.

> +	bcm2835aux_spi_reset_hw(bs);
> +
> +	/* disable HW block */
> +	bcm2835aux_spi_disable(bs);

  parent reply	other threads:[~2015-07-11  4:53 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-22 13:40 [PATCH 1/2] spi: bcm2835: add spi-bcm2835aux driver for the auxiliar spi1 and spi2 kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found] ` <1434980408-4086-1-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-06-22 13:40   ` [PATCH 2/2] dt: brcm,bcm2835-aux-spi: add binding documentation for new spi-bcm2835aux kernel-TqfNSX0MhmxHKSADF0wUEw
     [not found]     ` <1434980408-4086-2-git-send-email-kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-06-22 17:55       ` [PATCH 2/2] dt: brcm, bcm2835-aux-spi: " Stefan Wahren
     [not found]         ` <55884C2B.8040601-saaNCTdWVBT7BZbvpMY5sg@public.gmane.org>
2015-06-22 19:19           ` Martin Sperl
2015-06-22 14:08   ` [PATCH 1/2] spi: bcm2835: add spi-bcm2835aux driver for the auxiliar spi1 and spi2 Noralf Trønnes
2015-06-22 14:55   ` Jakub Kiciński
2015-06-22 15:26     ` Martin Sperl
     [not found]       ` <E72B3D8C-EA1B-4B4C-8EAF-C14A5631882E-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-06-25 14:19         ` Martin Sperl
     [not found]           ` <97C7561C-6D67-4F51-94BB-3B8D401D77A0-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-06-30  9:42             ` Mark Brown
     [not found]               ` <20150630094232.GM11162-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2015-07-01 19:39                 ` Martin Sperl
     [not found]                   ` <6A2CCE70-5DAF-4E86-A0A4-F5E93FD1B540-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-01 20:57                     ` Noralf Trønnes
     [not found]                       ` <55945448.7010502-L59+Z2yzLopAfugRpC6u6w@public.gmane.org>
2015-07-05  1:14                         ` Martin Sperl
     [not found]                           ` <1400E1A3-43E1-4D0E-A54D-E5D668A4C516-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-05 10:37                             ` Noralf Trønnes
     [not found]                               ` <55990904.9040002-L59+Z2yzLopAfugRpC6u6w@public.gmane.org>
2015-07-05 13:11                                 ` Martin Sperl
2015-07-11  4:41                             ` Stephen Warren
2015-07-11  4:37         ` Stephen Warren
2015-07-11  4:53   ` Stephen Warren [this message]
     [not found]     ` <55A0A150.3060809-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-07-12  2:10       ` Martin Sperl
     [not found]         ` <ECFBB7BF-1316-4565-B1F2-FB2651131882-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-14  4:56           ` Stephen Warren
     [not found]             ` <55A49662.3000706-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-07-14 12:39               ` Martin Sperl
     [not found]                 ` <2768BFA9-7FE9-4EDC-8692-AC3F070BD874-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-22  1:55                   ` Stephen Warren
     [not found]                     ` <55AEF828.20908-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-07-22 16:28                       ` Martin Sperl
     [not found]                         ` <0125992E-40F4-4702-8404-2943FF9A8788-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-24  4:09                           ` Stephen Warren
     [not found]                             ` <55B1BA7A.1090104-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-07-24  6:47                               ` Martin Sperl
     [not found]                                 ` <9005ABEC-C60A-4814-AD60-AD5BB09808F2-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-28  2:51                                   ` Stephen Warren
     [not found]                                     ` <55B6EE1A.2070605-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2015-07-28  6:18                                       ` Martin Sperl
     [not found]                                         ` <836DA157-3072-441A-A160-E1FDBB119E88-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-28 10:48                                           ` Martin Sperl
     [not found]                                             ` <55B75E07.1080104-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-29 16:37                                               ` Stefan Wahren
     [not found]                                                 ` <55B9014C.7020105-saaNCTdWVBT7BZbvpMY5sg@public.gmane.org>
2015-07-29 17:25                                                   ` Noralf Trønnes
2015-07-29 21:16                                                   ` Martin Sperl
     [not found]                                                     ` <C767C9AD-A9B5-428F-A207-D67269B380C6-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-30  5:36                                                       ` Stefan Wahren
     [not found]                                                         ` <55B9B7EF.2070108-saaNCTdWVBT7BZbvpMY5sg@public.gmane.org>
2015-07-30  6:45                                                           ` Martin Sperl
     [not found]                                                             ` <C2C16277-C6C1-4F86-BB88-580CF667EF24-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-30  7:10                                                               ` Martin Sperl
     [not found]                                                                 ` <97861F80-CF83-4FF2-B96E-CDFB1A8F4921-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-30 15:27                                                                   ` Martin Sperl
     [not found]                                                                     ` <E9EEB426-95DE-4785-949C-6A402A25E115-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org>
2015-07-31 18:42                                                                       ` Stefan Wahren
2015-08-01  2:55                                               ` Stephen Warren
2015-08-01  2:51                                           ` Stephen Warren

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=55A0A150.3060809@wwwdotorg.org \
    --to=swarren-3lzwwm7+weoh9zmkesr00q@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=kernel-TqfNSX0MhmxHKSADF0wUEw@public.gmane.org \
    --cc=linux-rpi-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.