From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752851AbbDCRxE (ORCPT ); Fri, 3 Apr 2015 13:53:04 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:36442 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751913AbbDCRxA (ORCPT ); Fri, 3 Apr 2015 13:53:00 -0400 Message-ID: <551ED345.1000702@gmail.com> Date: Fri, 03 Apr 2015 10:52:05 -0700 From: Florian Fainelli User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Andy Shevchenko , Jonathan Richardson CC: Mark Brown , Dmitry Torokhov , Anatol Pomazau , Scott Branden , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , "linux-kernel@vger.kernel.org" , linux-spi@vger.kernel.org, bcm-kernel-feedback-list , devicetree , Rafal Milecki Subject: Re: [PATCH 3/4] spi: bcm-mspi: Make BCMA optional to support non-BCMA chips References: <1428002603-21892-1-git-send-email-jonathar@broadcom.com> <1428002603-21892-4-git-send-email-jonathar@broadcom.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/04/15 06:38, Andy Shevchenko wrote: > On Thu, Apr 2, 2015 at 10:23 PM, Jonathan Richardson > wrote: >> The Broadcom MSPI controller is used on various chips. The driver only >> supported BCM53xx chips with BCMA (an AMBA bus variant). The driver is >> refactored to make BCMA optional and provides a new config for non BCMA >> systems. > >> struct bcm_mspi { >> + #ifdef CONFIG_SPI_BCMA_MSPI >> struct bcma_device *core; >> - struct spi_master *master; >> + #endif >> >> + void __iomem *base; >> + struct spi_master *master; >> size_t read_offset; > >> + void (*mspi_write)(struct bcm_mspi *mspi, u16 offset, u32 value); >> + u32 (*mspi_read)(struct bcm_mspi *mspi, u16 offset); >> +}; > > To avoid ugly ifdefs I think better to split driver to core part and > the actual driver part, at the end you will have something like > mspi-core.c mspi-53xx.c mspi-whatever.c. Check for example spi-dw*.c > Actually, I am really curious whether we need the special BCMA I/O accessors in the first place, cannot we just access the MSPI core on BCM53xx chips using regular MMIO? That would probably solve the "problem" entirely. Rafal, did you try this before? As for splitting the driver into a "library" driver which is mostly independent from the bus and a bus-specific wrapper, I think BCMA is really the only special case here, which is why I suggested earlier to Jonathan that we might just prefer ifdefing things out instead of creating a separate layer just for BCMA. -- Florian