From patchwork Mon Feb 27 13:34:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13153494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35961C7EE31 for ; Mon, 27 Feb 2023 13:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3kBdf/JS/4XLBy/o0r2zzFcBe/Td5mnUuOjnpkx+UQA=; b=FG8IWb68FN1f6q OBPBiH1CpdzBiEclTB9B5x6MhgEyeLjeEn7xPw/6fS9rj2YFrOlFivtNcAUA/qDKmJiMMQRglazMd PdUpeb7FxCFN33LW5fAJEAc4cj3kdTDZMFFUKPS6yei9aXRP0GkwZXXcJYtZ2ncdiTC0W3+pnDIH7 OUS0v6aslUl/UDErGamxz3qV7K01vrGIP6xZBJ9/FTw+A8nln9Hgmcfx1d5GiugnoDuhTv5++9YM3 KT7pE93v3R373uapYJVgqKfUp3ptYD5930TxOc++xJo3RJ1KD5sqaSJBKdEBjJQa2ZkD14QpLXiGS f0FfKS3L8ZZe/80FPkyg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfO-009mZ7-12; Mon, 27 Feb 2023 13:35:46 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdf6-009mSL-SZ for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2023 13:35:33 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF3A460E2C; Mon, 27 Feb 2023 13:35:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AADB3C4339E; Mon, 27 Feb 2023 13:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677504927; bh=evm2cwWmLNjJku1CkjApAKe7ySgjWdCrvoejhcV8Ygo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gBvKUCyOMQNZu5Y+VWnElXF/PkzKxZOhC0o7Mi+eWns4RIARyKXwPdyCEiPSjh3Rp 7kj31CcJY/PET0xQVARgmVRpeqoa69ro3ipk7Arfx2bDokOudFg8KUKLOQB2ljrkx4 y/P7ZZ0uSuN70jreXkkiw3IqfYNyTBiSIBWK82ZKb6TkdGD4lQzmIVYxdL1ZvTAEFv cG7/XfGtN10abT9SG9U73EksBlPd6JvS7bQ4tfboHiiSjqcbZaFBUqX78MldN7RLXS rp3eoZzLWMVHD04Dhfmhf1xFFowUY/gjBAckoAlcoeSNSuZNMIYGtSPF7jKsZPVEzk T59UdO+y+LyEg== From: Arnd Bergmann To: Dominik Brodowski , linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Bjorn Helgaas , Florian Fainelli , H Hartley Sweeten , Ian Abbott , Jakub Kicinski , Kevin Cernekee , Lukas Wunner , Manuel Lauss , Oliver Hartkopp , Olof Johansson , Robert Jarzmik , YOKOTA Hiroshi , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-mips@vger.kernel.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC 1/6] pccard: remove bcm63xx socket driver Date: Mon, 27 Feb 2023 14:34:52 +0100 Message-Id: <20230227133457.431729-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227133457.431729-1-arnd@kernel.org> References: <20230227133457.431729-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230227_053529_062545_01346F5B X-CRM114-Status: GOOD ( 35.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann The bcm63xx pcmcia driver is the only nonstandard cardbus implementation, everything else is handled by the yenta_socket driver. Upon a closer look, this seems entirely unused, because: - There are two ports for bcm63xx in arch/mips, both of which support the bcm6358 hardware, but the newer one does not use this driver at all. - The only distro I could find for bcm63xx is OpenWRT, but they do not enable pcmcia support. However they have 130 patches, a lot of which are likely required to run anything at all. - The device list at https://deviwiki.com/wiki/Broadcom only lists machines using mini-PCI cards rather than PCMCIA or Cardbus devices. - The cardbus support is entirely made up to work with the kernel subsystem, but the hardware appears to just be a normal PCI host that should work fine after removing all the cardbus code. Signed-off-by: Arnd Bergmann --- arch/mips/bcm63xx/Makefile | 2 +- arch/mips/bcm63xx/boards/board_bcm963xx.c | 14 - arch/mips/bcm63xx/dev-pcmcia.c | 144 ----- arch/mips/configs/bcm63xx_defconfig | 1 - .../asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h | 14 - arch/mips/pci/ops-bcm63xx.c | 294 ---------- arch/mips/pci/pci-bcm63xx.c | 44 -- drivers/pcmcia/Kconfig | 4 - drivers/pcmcia/Makefile | 1 - drivers/pcmcia/bcm63xx_pcmcia.c | 538 ------------------ drivers/pcmcia/bcm63xx_pcmcia.h | 61 -- 11 files changed, 1 insertion(+), 1116 deletions(-) delete mode 100644 arch/mips/bcm63xx/dev-pcmcia.c delete mode 100644 arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h delete mode 100644 drivers/pcmcia/bcm63xx_pcmcia.c delete mode 100644 drivers/pcmcia/bcm63xx_pcmcia.h diff --git a/arch/mips/bcm63xx/Makefile b/arch/mips/bcm63xx/Makefile index d89651e538f6..fccaeeee757d 100644 --- a/arch/mips/bcm63xx/Makefile +++ b/arch/mips/bcm63xx/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += clk.o cpu.o cs.o gpio.o irq.o nvram.o prom.o reset.o \ - setup.o timer.o dev-enet.o dev-flash.o dev-pcmcia.o \ + setup.o timer.o dev-enet.o dev-flash.o \ dev-rng.o dev-spi.o dev-hsspi.o dev-uart.o dev-wdt.o \ dev-usb-usbd.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c index 01aff80a5967..d88d3043a288 100644 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -266,7 +265,6 @@ static struct board_info __initdata board_96348gw_10 = { .expected_cpu_id = 0x6348, .has_ohci0 = 1, - .has_pccard = 1, .has_pci = 1, .has_uart0 = 1, @@ -317,7 +315,6 @@ static struct board_info __initdata board_96348gw_11 = { .expected_cpu_id = 0x6348, .has_ohci0 = 1, - .has_pccard = 1, .has_pci = 1, .has_uart0 = 1, @@ -418,7 +415,6 @@ static struct board_info __initdata board_FAST2404 = { .expected_cpu_id = 0x6348, .has_ohci0 = 1, - .has_pccard = 1, .has_pci = 1, .has_uart0 = 1, @@ -507,7 +503,6 @@ static struct board_info __initdata board_96358vw = { .has_ehci0 = 1, .has_ohci0 = 1, - .has_pccard = 1, .has_pci = 1, .has_uart0 = 1, @@ -557,7 +552,6 @@ static struct board_info __initdata board_96358vw2 = { .has_ehci0 = 1, .has_ohci0 = 1, - .has_pccard = 1, .has_pci = 1, .has_uart0 = 1, @@ -807,11 +801,6 @@ void __init board_prom_init(void) } #endif /* CONFIG_PCI */ - if (board.has_pccard) { - if (BCMCPU_IS_6348()) - val |= GPIO_MODE_6348_G1_MII_PCCARD; - } - if (board.has_enet0 && !board.enet0.use_internal_phy) { if (BCMCPU_IS_6348()) val |= GPIO_MODE_6348_G3_EXT_MII | @@ -861,9 +850,6 @@ int __init board_register_devices(void) if (board.has_uart1) bcm63xx_uart_register(1); - if (board.has_pccard) - bcm63xx_pcmcia_register(); - if (board.has_enet0 && !bcm63xx_nvram_get_mac_address(board.enet0.mac_addr)) bcm63xx_enet_register(0, &board.enet0); diff --git a/arch/mips/bcm63xx/dev-pcmcia.c b/arch/mips/bcm63xx/dev-pcmcia.c deleted file mode 100644 index 9496cd236951..000000000000 --- a/arch/mips/bcm63xx/dev-pcmcia.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 2008 Maxime Bizon - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static struct resource pcmcia_resources[] = { - /* pcmcia registers */ - { - /* start & end filled at runtime */ - .flags = IORESOURCE_MEM, - }, - - /* pcmcia memory zone resources */ - { - .start = BCM_PCMCIA_COMMON_BASE_PA, - .end = BCM_PCMCIA_COMMON_END_PA, - .flags = IORESOURCE_MEM, - }, - { - .start = BCM_PCMCIA_ATTR_BASE_PA, - .end = BCM_PCMCIA_ATTR_END_PA, - .flags = IORESOURCE_MEM, - }, - { - .start = BCM_PCMCIA_IO_BASE_PA, - .end = BCM_PCMCIA_IO_END_PA, - .flags = IORESOURCE_MEM, - }, - - /* PCMCIA irq */ - { - /* start filled at runtime */ - .flags = IORESOURCE_IRQ, - }, - - /* declare PCMCIA IO resource also */ - { - .start = BCM_PCMCIA_IO_BASE_PA, - .end = BCM_PCMCIA_IO_END_PA, - .flags = IORESOURCE_IO, - }, -}; - -static struct bcm63xx_pcmcia_platform_data pd; - -static struct platform_device bcm63xx_pcmcia_device = { - .name = "bcm63xx_pcmcia", - .id = 0, - .num_resources = ARRAY_SIZE(pcmcia_resources), - .resource = pcmcia_resources, - .dev = { - .platform_data = &pd, - }, -}; - -static int __init config_pcmcia_cs(unsigned int cs, - u32 base, unsigned int size) -{ - int ret; - - ret = bcm63xx_set_cs_status(cs, 0); - if (!ret) - ret = bcm63xx_set_cs_base(cs, base, size); - if (!ret) - ret = bcm63xx_set_cs_status(cs, 1); - return ret; -} - -static const struct { - unsigned int cs; - unsigned int base; - unsigned int size; -} pcmcia_cs[3] __initconst = { - { - .cs = MPI_CS_PCMCIA_COMMON, - .base = BCM_PCMCIA_COMMON_BASE_PA, - .size = BCM_PCMCIA_COMMON_SIZE - }, - { - .cs = MPI_CS_PCMCIA_ATTR, - .base = BCM_PCMCIA_ATTR_BASE_PA, - .size = BCM_PCMCIA_ATTR_SIZE - }, - { - .cs = MPI_CS_PCMCIA_IO, - .base = BCM_PCMCIA_IO_BASE_PA, - .size = BCM_PCMCIA_IO_SIZE - }, -}; - -int __init bcm63xx_pcmcia_register(void) -{ - int ret, i; - - if (!BCMCPU_IS_6348() && !BCMCPU_IS_6358()) - return 0; - - /* use correct pcmcia ready gpio depending on processor */ - switch (bcm63xx_get_cpu_id()) { - case BCM6348_CPU_ID: - pd.ready_gpio = 22; - break; - - case BCM6358_CPU_ID: - pd.ready_gpio = 18; - break; - - default: - return -ENODEV; - } - - pcmcia_resources[0].start = bcm63xx_regset_address(RSET_PCMCIA); - pcmcia_resources[0].end = pcmcia_resources[0].start + - RSET_PCMCIA_SIZE - 1; - pcmcia_resources[4].start = bcm63xx_get_irq_number(IRQ_PCMCIA); - - /* configure pcmcia chip selects */ - for (i = 0; i < 3; i++) { - ret = config_pcmcia_cs(pcmcia_cs[i].cs, - pcmcia_cs[i].base, - pcmcia_cs[i].size); - if (ret) - goto out_err; - } - - return platform_device_register(&bcm63xx_pcmcia_device); - -out_err: - pr_err("unable to set pcmcia chip select\n"); - return ret; -} diff --git a/arch/mips/configs/bcm63xx_defconfig b/arch/mips/configs/bcm63xx_defconfig index 34d0ca638ef0..d1a185c20f00 100644 --- a/arch/mips/configs/bcm63xx_defconfig +++ b/arch/mips/configs/bcm63xx_defconfig @@ -19,7 +19,6 @@ CONFIG_BCM63XX_CPU_6358=y # CONFIG_SECCOMP is not set CONFIG_PCI=y CONFIG_PCCARD=y -CONFIG_PCMCIA_BCM63XX=y # CONFIG_BLK_DEV_BSG is not set CONFIG_NET=y CONFIG_UNIX=y diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h deleted file mode 100644 index 01674ac58bb5..000000000000 --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_pcmcia.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef BCM63XX_DEV_PCMCIA_H_ -#define BCM63XX_DEV_PCMCIA_H_ - -/* - * PCMCIA driver platform data - */ -struct bcm63xx_pcmcia_platform_data { - unsigned int ready_gpio; -}; - -int bcm63xx_pcmcia_register(void); - -#endif /* BCM63XX_DEV_PCMCIA_H_ */ diff --git a/arch/mips/pci/ops-bcm63xx.c b/arch/mips/pci/ops-bcm63xx.c index dc6dc2741272..4cb6185a9f66 100644 --- a/arch/mips/pci/ops-bcm63xx.c +++ b/arch/mips/pci/ops-bcm63xx.c @@ -151,9 +151,6 @@ static int bcm63xx_pci_read(struct pci_bus *bus, unsigned int devfn, type = bus->parent ? 1 : 0; - if (type == 0 && PCI_SLOT(devfn) == CARDBUS_PCI_IDSEL) - return PCIBIOS_DEVICE_NOT_FOUND; - return bcm63xx_do_cfg_read(type, bus->number, devfn, where, size, val); } @@ -165,9 +162,6 @@ static int bcm63xx_pci_write(struct pci_bus *bus, unsigned int devfn, type = bus->parent ? 1 : 0; - if (type == 0 && PCI_SLOT(devfn) == CARDBUS_PCI_IDSEL) - return PCIBIOS_DEVICE_NOT_FOUND; - return bcm63xx_do_cfg_write(type, bus->number, devfn, where, size, val); } @@ -177,294 +171,6 @@ struct pci_ops bcm63xx_pci_ops = { .write = bcm63xx_pci_write }; -#ifdef CONFIG_CARDBUS -/* - * emulate configuration read access on a cardbus bridge - */ -#define FAKE_CB_BRIDGE_SLOT 0x1e - -static int fake_cb_bridge_bus_number = -1; - -static struct { - u16 pci_command; - u8 cb_latency; - u8 subordinate_busn; - u8 cardbus_busn; - u8 pci_busn; - int bus_assigned; - u16 bridge_control; - - u32 mem_base0; - u32 mem_limit0; - u32 mem_base1; - u32 mem_limit1; - - u32 io_base0; - u32 io_limit0; - u32 io_base1; - u32 io_limit1; -} fake_cb_bridge_regs; - -static int fake_cb_bridge_read(int where, int size, u32 *val) -{ - unsigned int reg; - u32 data; - - data = 0; - reg = where >> 2; - switch (reg) { - case (PCI_VENDOR_ID >> 2): - case (PCI_CB_SUBSYSTEM_VENDOR_ID >> 2): - /* create dummy vendor/device id from our cpu id */ - data = (bcm63xx_get_cpu_id() << 16) | PCI_VENDOR_ID_BROADCOM; - break; - - case (PCI_COMMAND >> 2): - data = (PCI_STATUS_DEVSEL_SLOW << 16); - data |= fake_cb_bridge_regs.pci_command; - break; - - case (PCI_CLASS_REVISION >> 2): - data = (PCI_CLASS_BRIDGE_CARDBUS << 16); - break; - - case (PCI_CACHE_LINE_SIZE >> 2): - data = (PCI_HEADER_TYPE_CARDBUS << 16); - break; - - case (PCI_INTERRUPT_LINE >> 2): - /* bridge control */ - data = (fake_cb_bridge_regs.bridge_control << 16); - /* pin:intA line:0xff */ - data |= (0x1 << 8) | 0xff; - break; - - case (PCI_CB_PRIMARY_BUS >> 2): - data = (fake_cb_bridge_regs.cb_latency << 24); - data |= (fake_cb_bridge_regs.subordinate_busn << 16); - data |= (fake_cb_bridge_regs.cardbus_busn << 8); - data |= fake_cb_bridge_regs.pci_busn; - break; - - case (PCI_CB_MEMORY_BASE_0 >> 2): - data = fake_cb_bridge_regs.mem_base0; - break; - - case (PCI_CB_MEMORY_LIMIT_0 >> 2): - data = fake_cb_bridge_regs.mem_limit0; - break; - - case (PCI_CB_MEMORY_BASE_1 >> 2): - data = fake_cb_bridge_regs.mem_base1; - break; - - case (PCI_CB_MEMORY_LIMIT_1 >> 2): - data = fake_cb_bridge_regs.mem_limit1; - break; - - case (PCI_CB_IO_BASE_0 >> 2): - /* | 1 for 32bits io support */ - data = fake_cb_bridge_regs.io_base0 | 0x1; - break; - - case (PCI_CB_IO_LIMIT_0 >> 2): - data = fake_cb_bridge_regs.io_limit0; - break; - - case (PCI_CB_IO_BASE_1 >> 2): - /* | 1 for 32bits io support */ - data = fake_cb_bridge_regs.io_base1 | 0x1; - break; - - case (PCI_CB_IO_LIMIT_1 >> 2): - data = fake_cb_bridge_regs.io_limit1; - break; - } - - *val = postprocess_read(data, where, size); - return PCIBIOS_SUCCESSFUL; -} - -/* - * emulate configuration write access on a cardbus bridge - */ -static int fake_cb_bridge_write(int where, int size, u32 val) -{ - unsigned int reg; - u32 data, tmp; - int ret; - - ret = fake_cb_bridge_read((where & ~0x3), 4, &data); - if (ret != PCIBIOS_SUCCESSFUL) - return ret; - - data = preprocess_write(data, val, where, size); - - reg = where >> 2; - switch (reg) { - case (PCI_COMMAND >> 2): - fake_cb_bridge_regs.pci_command = (data & 0xffff); - break; - - case (PCI_CB_PRIMARY_BUS >> 2): - fake_cb_bridge_regs.cb_latency = (data >> 24) & 0xff; - fake_cb_bridge_regs.subordinate_busn = (data >> 16) & 0xff; - fake_cb_bridge_regs.cardbus_busn = (data >> 8) & 0xff; - fake_cb_bridge_regs.pci_busn = data & 0xff; - if (fake_cb_bridge_regs.cardbus_busn) - fake_cb_bridge_regs.bus_assigned = 1; - break; - - case (PCI_INTERRUPT_LINE >> 2): - tmp = (data >> 16) & 0xffff; - /* disable memory prefetch support */ - tmp &= ~PCI_CB_BRIDGE_CTL_PREFETCH_MEM0; - tmp &= ~PCI_CB_BRIDGE_CTL_PREFETCH_MEM1; - fake_cb_bridge_regs.bridge_control = tmp; - break; - - case (PCI_CB_MEMORY_BASE_0 >> 2): - fake_cb_bridge_regs.mem_base0 = data; - break; - - case (PCI_CB_MEMORY_LIMIT_0 >> 2): - fake_cb_bridge_regs.mem_limit0 = data; - break; - - case (PCI_CB_MEMORY_BASE_1 >> 2): - fake_cb_bridge_regs.mem_base1 = data; - break; - - case (PCI_CB_MEMORY_LIMIT_1 >> 2): - fake_cb_bridge_regs.mem_limit1 = data; - break; - - case (PCI_CB_IO_BASE_0 >> 2): - fake_cb_bridge_regs.io_base0 = data; - break; - - case (PCI_CB_IO_LIMIT_0 >> 2): - fake_cb_bridge_regs.io_limit0 = data; - break; - - case (PCI_CB_IO_BASE_1 >> 2): - fake_cb_bridge_regs.io_base1 = data; - break; - - case (PCI_CB_IO_LIMIT_1 >> 2): - fake_cb_bridge_regs.io_limit1 = data; - break; - } - - return PCIBIOS_SUCCESSFUL; -} - -static int bcm63xx_cb_read(struct pci_bus *bus, unsigned int devfn, - int where, int size, u32 *val) -{ - /* snoop access to slot 0x1e on root bus, we fake a cardbus - * bridge at this location */ - if (!bus->parent && PCI_SLOT(devfn) == FAKE_CB_BRIDGE_SLOT) { - fake_cb_bridge_bus_number = bus->number; - return fake_cb_bridge_read(where, size, val); - } - - /* a configuration cycle for the device behind the cardbus - * bridge is actually done as a type 0 cycle on the primary - * bus. This means that only one device can be on the cardbus - * bus */ - if (fake_cb_bridge_regs.bus_assigned && - bus->number == fake_cb_bridge_regs.cardbus_busn && - PCI_SLOT(devfn) == 0) - return bcm63xx_do_cfg_read(0, 0, - PCI_DEVFN(CARDBUS_PCI_IDSEL, 0), - where, size, val); - - return PCIBIOS_DEVICE_NOT_FOUND; -} - -static int bcm63xx_cb_write(struct pci_bus *bus, unsigned int devfn, - int where, int size, u32 val) -{ - if (!bus->parent && PCI_SLOT(devfn) == FAKE_CB_BRIDGE_SLOT) { - fake_cb_bridge_bus_number = bus->number; - return fake_cb_bridge_write(where, size, val); - } - - if (fake_cb_bridge_regs.bus_assigned && - bus->number == fake_cb_bridge_regs.cardbus_busn && - PCI_SLOT(devfn) == 0) - return bcm63xx_do_cfg_write(0, 0, - PCI_DEVFN(CARDBUS_PCI_IDSEL, 0), - where, size, val); - - return PCIBIOS_DEVICE_NOT_FOUND; -} - -struct pci_ops bcm63xx_cb_ops = { - .read = bcm63xx_cb_read, - .write = bcm63xx_cb_write, -}; - -/* - * only one IO window, so it cannot be shared by PCI and cardbus, use - * fixup to choose and detect unhandled configuration - */ -static void bcm63xx_fixup(struct pci_dev *dev) -{ - static int io_window = -1; - int i, found, new_io_window; - u32 val; - - /* look for any io resource */ - found = 0; - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { - if (pci_resource_flags(dev, i) & IORESOURCE_IO) { - found = 1; - break; - } - } - - if (!found) - return; - - /* skip our fake bus with only cardbus bridge on it */ - if (dev->bus->number == fake_cb_bridge_bus_number) - return; - - /* find on which bus the device is */ - if (fake_cb_bridge_regs.bus_assigned && - dev->bus->number == fake_cb_bridge_regs.cardbus_busn && - PCI_SLOT(dev->devfn) == 0) - new_io_window = 1; - else - new_io_window = 0; - - if (new_io_window == io_window) - return; - - if (io_window != -1) { - printk(KERN_ERR "bcm63xx: both PCI and cardbus devices " - "need IO, which hardware cannot do\n"); - return; - } - - printk(KERN_INFO "bcm63xx: PCI IO window assigned to %s\n", - (new_io_window == 0) ? "PCI" : "cardbus"); - - val = bcm_mpi_readl(MPI_L2PIOREMAP_REG); - if (io_window) - val |= MPI_L2PREMAP_IS_CARDBUS_MASK; - else - val &= ~MPI_L2PREMAP_IS_CARDBUS_MASK; - bcm_mpi_writel(val, MPI_L2PIOREMAP_REG); - - io_window = new_io_window; -} - -DECLARE_PCI_FIXUP_ENABLE(PCI_ANY_ID, PCI_ANY_ID, bcm63xx_fixup); -#endif - static int bcm63xx_pcie_can_access(struct pci_bus *bus, int devfn) { switch (bus->number) { diff --git a/arch/mips/pci/pci-bcm63xx.c b/arch/mips/pci/pci-bcm63xx.c index ac83243772d2..ebe062b149f6 100644 --- a/arch/mips/pci/pci-bcm63xx.c +++ b/arch/mips/pci/pci-bcm63xx.c @@ -34,11 +34,7 @@ static struct resource bcm_pci_mem_resource = { static struct resource bcm_pci_io_resource = { .name = "bcm63xx PCI IO space", .start = BCM_PCI_IO_BASE_PA, -#ifdef CONFIG_CARDBUS - .end = BCM_PCI_IO_HALF_PA, -#else .end = BCM_PCI_IO_END_PA, -#endif .flags = IORESOURCE_IO }; @@ -48,33 +44,6 @@ struct pci_controller bcm63xx_controller = { .mem_resource = &bcm_pci_mem_resource, }; -/* - * We handle cardbus via a fake Cardbus bridge, memory and io spaces - * have to be clearly separated from PCI one since we have different - * memory decoder. - */ -#ifdef CONFIG_CARDBUS -static struct resource bcm_cb_mem_resource = { - .name = "bcm63xx Cardbus memory space", - .start = BCM_CB_MEM_BASE_PA, - .end = BCM_CB_MEM_END_PA, - .flags = IORESOURCE_MEM -}; - -static struct resource bcm_cb_io_resource = { - .name = "bcm63xx Cardbus IO space", - .start = BCM_PCI_IO_HALF_PA + 1, - .end = BCM_PCI_IO_END_PA, - .flags = IORESOURCE_IO -}; - -struct pci_controller bcm63xx_cb_controller = { - .pci_ops = &bcm63xx_cb_ops, - .io_resource = &bcm_cb_io_resource, - .mem_resource = &bcm_cb_mem_resource, -}; -#endif - static struct resource bcm_pcie_mem_resource = { .name = "bcm63xx PCIe memory space", .start = BCM_PCIE_MEM_BASE_PA, @@ -238,17 +207,8 @@ static int __init bcm63xx_register_pci(void) val |= (CARDBUS_PCI_IDSEL << PCMCIA_C1_CBIDSEL_SHIFT); bcm_pcmcia_writel(val, PCMCIA_C1_REG); -#ifdef CONFIG_CARDBUS - /* setup local bus to PCI access (Cardbus memory) */ - val = BCM_CB_MEM_BASE_PA & MPI_L2P_BASE_MASK; - bcm_mpi_writel(val, MPI_L2PMEMBASE2_REG); - bcm_mpi_writel(~(BCM_CB_MEM_SIZE - 1), MPI_L2PMEMRANGE2_REG); - val |= MPI_L2PREMAP_ENABLED_MASK | MPI_L2PREMAP_IS_CARDBUS_MASK; - bcm_mpi_writel(val, MPI_L2PMEMREMAP2_REG); -#else /* disable second access windows */ bcm_mpi_writel(0, MPI_L2PMEMREMAP2_REG); -#endif /* setup local bus to PCI access (IO memory), we have only 1 * IO window for both PCI and cardbus, but it cannot handle @@ -318,10 +278,6 @@ static int __init bcm63xx_register_pci(void) register_pci_controller(&bcm63xx_controller); -#ifdef CONFIG_CARDBUS - register_pci_controller(&bcm63xx_cb_controller); -#endif - /* mark memory space used for IO mapping as reserved */ request_mem_region(BCM_PCI_IO_BASE_PA, BCM_PCI_IO_SIZE, "bcm63xx PCI IO space"); diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 1525023e49b6..26c89eefa18e 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -168,10 +168,6 @@ config PCMCIA_XXS1500 This driver is also available as a module called xxs1500_ss.ko -config PCMCIA_BCM63XX - tristate "bcm63xx pcmcia support" - depends on BCM63XX && PCMCIA - config PCMCIA_SOC_COMMON tristate diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index b3a2accf47af..67d447c62b8d 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -28,7 +28,6 @@ obj-$(CONFIG_PCMCIA_SOC_COMMON) += soc_common.o obj-$(CONFIG_PCMCIA_SA11XX_BASE) += sa11xx_base.o obj-$(CONFIG_PCMCIA_SA1100) += sa1100_cs.o obj-$(CONFIG_PCMCIA_SA1111) += sa1111_cs.o -obj-$(CONFIG_PCMCIA_BCM63XX) += bcm63xx_pcmcia.o obj-$(CONFIG_OMAP_CF) += omap_cf.o obj-$(CONFIG_ELECTRA_CF) += electra_cf.o obj-$(CONFIG_PCMCIA_ALCHEMY_DEVBOARD) += db1xxx_ss.o diff --git a/drivers/pcmcia/bcm63xx_pcmcia.c b/drivers/pcmcia/bcm63xx_pcmcia.c deleted file mode 100644 index dd3c26099048..000000000000 --- a/drivers/pcmcia/bcm63xx_pcmcia.c +++ /dev/null @@ -1,538 +0,0 @@ -/* - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. - * - * Copyright (C) 2008 Maxime Bizon - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "bcm63xx_pcmcia.h" - -#define PFX "bcm63xx_pcmcia: " - -#ifdef CONFIG_CARDBUS -/* if cardbus is used, platform device needs reference to actual pci - * device */ -static struct pci_dev *bcm63xx_cb_dev; -#endif - -/* - * read/write helper for pcmcia regs - */ -static inline u32 pcmcia_readl(struct bcm63xx_pcmcia_socket *skt, u32 off) -{ - return bcm_readl(skt->base + off); -} - -static inline void pcmcia_writel(struct bcm63xx_pcmcia_socket *skt, - u32 val, u32 off) -{ - bcm_writel(val, skt->base + off); -} - -/* - * This callback should (re-)initialise the socket, turn on status - * interrupts and PCMCIA bus, and wait for power to stabilise so that - * the card status signals report correctly. - * - * Hardware cannot do that. - */ -static int bcm63xx_pcmcia_sock_init(struct pcmcia_socket *sock) -{ - return 0; -} - -/* - * This callback should remove power on the socket, disable IRQs from - * the card, turn off status interrupts, and disable the PCMCIA bus. - * - * Hardware cannot do that. - */ -static int bcm63xx_pcmcia_suspend(struct pcmcia_socket *sock) -{ - return 0; -} - -/* - * Implements the set_socket() operation for the in-kernel PCMCIA - * service (formerly SS_SetSocket in Card Services). We more or - * less punt all of this work and let the kernel handle the details - * of power configuration, reset, &c. We also record the value of - * `state' in order to regurgitate it to the PCMCIA core later. - */ -static int bcm63xx_pcmcia_set_socket(struct pcmcia_socket *sock, - socket_state_t *state) -{ - struct bcm63xx_pcmcia_socket *skt; - unsigned long flags; - u32 val; - - skt = sock->driver_data; - - spin_lock_irqsave(&skt->lock, flags); - - /* note: hardware cannot control socket power, so we will - * always report SS_POWERON */ - - /* apply socket reset */ - val = pcmcia_readl(skt, PCMCIA_C1_REG); - if (state->flags & SS_RESET) - val |= PCMCIA_C1_RESET_MASK; - else - val &= ~PCMCIA_C1_RESET_MASK; - - /* reverse reset logic for cardbus card */ - if (skt->card_detected && (skt->card_type & CARD_CARDBUS)) - val ^= PCMCIA_C1_RESET_MASK; - - pcmcia_writel(skt, val, PCMCIA_C1_REG); - - /* keep requested state for event reporting */ - skt->requested_state = *state; - - spin_unlock_irqrestore(&skt->lock, flags); - - return 0; -} - -/* - * identity cardtype from VS[12] input, CD[12] input while only VS2 is - * floating, and CD[12] input while only VS1 is floating - */ -enum { - IN_VS1 = (1 << 0), - IN_VS2 = (1 << 1), - IN_CD1_VS2H = (1 << 2), - IN_CD2_VS2H = (1 << 3), - IN_CD1_VS1H = (1 << 4), - IN_CD2_VS1H = (1 << 5), -}; - -static const u8 vscd_to_cardtype[] = { - - /* VS1 float, VS2 float */ - [IN_VS1 | IN_VS2] = (CARD_PCCARD | CARD_5V), - - /* VS1 grounded, VS2 float */ - [IN_VS2] = (CARD_PCCARD | CARD_5V | CARD_3V), - - /* VS1 grounded, VS2 grounded */ - [0] = (CARD_PCCARD | CARD_5V | CARD_3V | CARD_XV), - - /* VS1 tied to CD1, VS2 float */ - [IN_VS1 | IN_VS2 | IN_CD1_VS1H] = (CARD_CARDBUS | CARD_3V), - - /* VS1 grounded, VS2 tied to CD2 */ - [IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V | CARD_XV), - - /* VS1 tied to CD2, VS2 grounded */ - [IN_VS1 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_3V | CARD_XV | CARD_YV), - - /* VS1 float, VS2 grounded */ - [IN_VS1] = (CARD_PCCARD | CARD_XV), - - /* VS1 float, VS2 tied to CD2 */ - [IN_VS1 | IN_VS2 | IN_CD2_VS2H] = (CARD_CARDBUS | CARD_3V), - - /* VS1 float, VS2 tied to CD1 */ - [IN_VS1 | IN_VS2 | IN_CD1_VS2H] = (CARD_CARDBUS | CARD_XV | CARD_YV), - - /* VS1 tied to CD2, VS2 float */ - [IN_VS1 | IN_VS2 | IN_CD2_VS1H] = (CARD_CARDBUS | CARD_YV), - - /* VS2 grounded, VS1 is tied to CD1, CD2 is grounded */ - [IN_VS1 | IN_CD1_VS1H] = 0, /* ignore cardbay */ -}; - -/* - * poll hardware to check card insertion status - */ -static unsigned int __get_socket_status(struct bcm63xx_pcmcia_socket *skt) -{ - unsigned int stat; - u32 val; - - stat = 0; - - /* check CD for card presence */ - val = pcmcia_readl(skt, PCMCIA_C1_REG); - - if (!(val & PCMCIA_C1_CD1_MASK) && !(val & PCMCIA_C1_CD2_MASK)) - stat |= SS_DETECT; - - /* if new insertion, detect cardtype */ - if ((stat & SS_DETECT) && !skt->card_detected) { - unsigned int stat = 0; - - /* float VS1, float VS2 */ - val |= PCMCIA_C1_VS1OE_MASK; - val |= PCMCIA_C1_VS2OE_MASK; - pcmcia_writel(skt, val, PCMCIA_C1_REG); - - /* wait for output to stabilize and read VS[12] */ - udelay(10); - val = pcmcia_readl(skt, PCMCIA_C1_REG); - stat |= (val & PCMCIA_C1_VS1_MASK) ? IN_VS1 : 0; - stat |= (val & PCMCIA_C1_VS2_MASK) ? IN_VS2 : 0; - - /* drive VS1 low, float VS2 */ - val &= ~PCMCIA_C1_VS1OE_MASK; - val |= PCMCIA_C1_VS2OE_MASK; - pcmcia_writel(skt, val, PCMCIA_C1_REG); - - /* wait for output to stabilize and read CD[12] */ - udelay(10); - val = pcmcia_readl(skt, PCMCIA_C1_REG); - stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS2H : 0; - stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS2H : 0; - - /* float VS1, drive VS2 low */ - val |= PCMCIA_C1_VS1OE_MASK; - val &= ~PCMCIA_C1_VS2OE_MASK; - pcmcia_writel(skt, val, PCMCIA_C1_REG); - - /* wait for output to stabilize and read CD[12] */ - udelay(10); - val = pcmcia_readl(skt, PCMCIA_C1_REG); - stat |= (val & PCMCIA_C1_CD1_MASK) ? IN_CD1_VS1H : 0; - stat |= (val & PCMCIA_C1_CD2_MASK) ? IN_CD2_VS1H : 0; - - /* guess cardtype from all this */ - skt->card_type = vscd_to_cardtype[stat]; - if (!skt->card_type) - dev_err(&skt->socket.dev, "unsupported card type\n"); - - /* drive both VS pin to 0 again */ - val &= ~(PCMCIA_C1_VS1OE_MASK | PCMCIA_C1_VS2OE_MASK); - - /* enable correct logic */ - val &= ~(PCMCIA_C1_EN_PCMCIA_MASK | PCMCIA_C1_EN_CARDBUS_MASK); - if (skt->card_type & CARD_PCCARD) - val |= PCMCIA_C1_EN_PCMCIA_MASK; - else - val |= PCMCIA_C1_EN_CARDBUS_MASK; - - pcmcia_writel(skt, val, PCMCIA_C1_REG); - } - skt->card_detected = (stat & SS_DETECT) ? 1 : 0; - - /* report card type/voltage */ - if (skt->card_type & CARD_CARDBUS) - stat |= SS_CARDBUS; - if (skt->card_type & CARD_3V) - stat |= SS_3VCARD; - if (skt->card_type & CARD_XV) - stat |= SS_XVCARD; - stat |= SS_POWERON; - - if (gpio_get_value(skt->pd->ready_gpio)) - stat |= SS_READY; - - return stat; -} - -/* - * core request to get current socket status - */ -static int bcm63xx_pcmcia_get_status(struct pcmcia_socket *sock, - unsigned int *status) -{ - struct bcm63xx_pcmcia_socket *skt; - - skt = sock->driver_data; - - spin_lock_bh(&skt->lock); - *status = __get_socket_status(skt); - spin_unlock_bh(&skt->lock); - - return 0; -} - -/* - * socket polling timer callback - */ -static void bcm63xx_pcmcia_poll(struct timer_list *t) -{ - struct bcm63xx_pcmcia_socket *skt; - unsigned int stat, events; - - skt = from_timer(skt, t, timer); - - spin_lock_bh(&skt->lock); - - stat = __get_socket_status(skt); - - /* keep only changed bits, and mask with required one from the - * core */ - events = (stat ^ skt->old_status) & skt->requested_state.csc_mask; - skt->old_status = stat; - spin_unlock_bh(&skt->lock); - - if (events) - pcmcia_parse_events(&skt->socket, events); - - mod_timer(&skt->timer, - jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE)); -} - -static int bcm63xx_pcmcia_set_io_map(struct pcmcia_socket *sock, - struct pccard_io_map *map) -{ - /* this doesn't seem to be called by pcmcia layer if static - * mapping is used */ - return 0; -} - -static int bcm63xx_pcmcia_set_mem_map(struct pcmcia_socket *sock, - struct pccard_mem_map *map) -{ - struct bcm63xx_pcmcia_socket *skt; - struct resource *res; - - skt = sock->driver_data; - if (map->flags & MAP_ATTRIB) - res = skt->attr_res; - else - res = skt->common_res; - - map->static_start = res->start + map->card_start; - return 0; -} - -static struct pccard_operations bcm63xx_pcmcia_operations = { - .init = bcm63xx_pcmcia_sock_init, - .suspend = bcm63xx_pcmcia_suspend, - .get_status = bcm63xx_pcmcia_get_status, - .set_socket = bcm63xx_pcmcia_set_socket, - .set_io_map = bcm63xx_pcmcia_set_io_map, - .set_mem_map = bcm63xx_pcmcia_set_mem_map, -}; - -/* - * register pcmcia socket to core - */ -static int bcm63xx_drv_pcmcia_probe(struct platform_device *pdev) -{ - struct bcm63xx_pcmcia_socket *skt; - struct pcmcia_socket *sock; - struct resource *res; - unsigned int regmem_size = 0, iomem_size = 0; - u32 val; - int ret; - int irq; - - skt = kzalloc(sizeof(*skt), GFP_KERNEL); - if (!skt) - return -ENOMEM; - spin_lock_init(&skt->lock); - sock = &skt->socket; - sock->driver_data = skt; - - /* make sure we have all resources we need */ - skt->common_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - skt->attr_res = platform_get_resource(pdev, IORESOURCE_MEM, 2); - irq = platform_get_irq(pdev, 0); - skt->pd = pdev->dev.platform_data; - if (!skt->common_res || !skt->attr_res || (irq < 0) || !skt->pd) { - ret = -EINVAL; - goto err; - } - - /* remap pcmcia registers */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - regmem_size = resource_size(res); - if (!request_mem_region(res->start, regmem_size, "bcm63xx_pcmcia")) { - ret = -EINVAL; - goto err; - } - skt->reg_res = res; - - skt->base = ioremap(res->start, regmem_size); - if (!skt->base) { - ret = -ENOMEM; - goto err; - } - - /* remap io registers */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 3); - iomem_size = resource_size(res); - skt->io_base = ioremap(res->start, iomem_size); - if (!skt->io_base) { - ret = -ENOMEM; - goto err; - } - - /* resources are static */ - sock->resource_ops = &pccard_static_ops; - sock->ops = &bcm63xx_pcmcia_operations; - sock->owner = THIS_MODULE; - sock->dev.parent = &pdev->dev; - sock->features = SS_CAP_STATIC_MAP | SS_CAP_PCCARD; - sock->io_offset = (unsigned long)skt->io_base; - sock->pci_irq = irq; - -#ifdef CONFIG_CARDBUS - sock->cb_dev = bcm63xx_cb_dev; - if (bcm63xx_cb_dev) - sock->features |= SS_CAP_CARDBUS; -#endif - - /* assume common & attribute memory have the same size */ - sock->map_size = resource_size(skt->common_res); - - /* initialize polling timer */ - timer_setup(&skt->timer, bcm63xx_pcmcia_poll, 0); - - /* initialize pcmcia control register, drive VS[12] to 0, - * leave CB IDSEL to the old value since it is set by the PCI - * layer */ - val = pcmcia_readl(skt, PCMCIA_C1_REG); - val &= PCMCIA_C1_CBIDSEL_MASK; - val |= PCMCIA_C1_EN_PCMCIA_GPIO_MASK; - pcmcia_writel(skt, val, PCMCIA_C1_REG); - - /* - * Hardware has only one set of timings registers, not one for - * each memory access type, so we configure them for the - * slowest one: attribute memory. - */ - val = PCMCIA_C2_DATA16_MASK; - val |= 10 << PCMCIA_C2_RWCOUNT_SHIFT; - val |= 6 << PCMCIA_C2_INACTIVE_SHIFT; - val |= 3 << PCMCIA_C2_SETUP_SHIFT; - val |= 3 << PCMCIA_C2_HOLD_SHIFT; - pcmcia_writel(skt, val, PCMCIA_C2_REG); - - ret = pcmcia_register_socket(sock); - if (ret) - goto err; - - /* start polling socket */ - mod_timer(&skt->timer, - jiffies + msecs_to_jiffies(BCM63XX_PCMCIA_POLL_RATE)); - - platform_set_drvdata(pdev, skt); - return 0; - -err: - if (skt->io_base) - iounmap(skt->io_base); - if (skt->base) - iounmap(skt->base); - if (skt->reg_res) - release_mem_region(skt->reg_res->start, regmem_size); - kfree(skt); - return ret; -} - -static int bcm63xx_drv_pcmcia_remove(struct platform_device *pdev) -{ - struct bcm63xx_pcmcia_socket *skt; - struct resource *res; - - skt = platform_get_drvdata(pdev); - timer_shutdown_sync(&skt->timer); - iounmap(skt->base); - iounmap(skt->io_base); - res = skt->reg_res; - release_mem_region(res->start, resource_size(res)); - kfree(skt); - return 0; -} - -struct platform_driver bcm63xx_pcmcia_driver = { - .probe = bcm63xx_drv_pcmcia_probe, - .remove = bcm63xx_drv_pcmcia_remove, - .driver = { - .name = "bcm63xx_pcmcia", - .owner = THIS_MODULE, - }, -}; - -#ifdef CONFIG_CARDBUS -static int bcm63xx_cb_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - /* keep pci device */ - bcm63xx_cb_dev = dev; - return platform_driver_register(&bcm63xx_pcmcia_driver); -} - -static void bcm63xx_cb_exit(struct pci_dev *dev) -{ - platform_driver_unregister(&bcm63xx_pcmcia_driver); - bcm63xx_cb_dev = NULL; -} - -static const struct pci_device_id bcm63xx_cb_table[] = { - { - .vendor = PCI_VENDOR_ID_BROADCOM, - .device = BCM6348_CPU_ID, - .subvendor = PCI_VENDOR_ID_BROADCOM, - .subdevice = PCI_ANY_ID, - .class = PCI_CLASS_BRIDGE_CARDBUS << 8, - .class_mask = ~0, - }, - - { - .vendor = PCI_VENDOR_ID_BROADCOM, - .device = BCM6358_CPU_ID, - .subvendor = PCI_VENDOR_ID_BROADCOM, - .subdevice = PCI_ANY_ID, - .class = PCI_CLASS_BRIDGE_CARDBUS << 8, - .class_mask = ~0, - }, - - { }, -}; - -MODULE_DEVICE_TABLE(pci, bcm63xx_cb_table); - -static struct pci_driver bcm63xx_cardbus_driver = { - .name = "bcm63xx_cardbus", - .id_table = bcm63xx_cb_table, - .probe = bcm63xx_cb_probe, - .remove = bcm63xx_cb_exit, -}; -#endif - -/* - * if cardbus support is enabled, register our platform device after - * our fake cardbus bridge has been registered - */ -static int __init bcm63xx_pcmcia_init(void) -{ -#ifdef CONFIG_CARDBUS - return pci_register_driver(&bcm63xx_cardbus_driver); -#else - return platform_driver_register(&bcm63xx_pcmcia_driver); -#endif -} - -static void __exit bcm63xx_pcmcia_exit(void) -{ -#ifdef CONFIG_CARDBUS - return pci_unregister_driver(&bcm63xx_cardbus_driver); -#else - platform_driver_unregister(&bcm63xx_pcmcia_driver); -#endif -} - -module_init(bcm63xx_pcmcia_init); -module_exit(bcm63xx_pcmcia_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Maxime Bizon "); -MODULE_DESCRIPTION("Linux PCMCIA Card Services: bcm63xx Socket Controller"); diff --git a/drivers/pcmcia/bcm63xx_pcmcia.h b/drivers/pcmcia/bcm63xx_pcmcia.h deleted file mode 100644 index 2122c59a1c4a..000000000000 --- a/drivers/pcmcia/bcm63xx_pcmcia.h +++ /dev/null @@ -1,61 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef BCM63XX_PCMCIA_H_ -#define BCM63XX_PCMCIA_H_ - -#include -#include -#include -#include - -/* socket polling rate in ms */ -#define BCM63XX_PCMCIA_POLL_RATE 500 - -enum { - CARD_CARDBUS = (1 << 0), - CARD_PCCARD = (1 << 1), - CARD_5V = (1 << 2), - CARD_3V = (1 << 3), - CARD_XV = (1 << 4), - CARD_YV = (1 << 5), -}; - -struct bcm63xx_pcmcia_socket { - struct pcmcia_socket socket; - - /* platform specific data */ - struct bcm63xx_pcmcia_platform_data *pd; - - /* all regs access are protected by this spinlock */ - spinlock_t lock; - - /* pcmcia registers resource */ - struct resource *reg_res; - - /* base remapped address of registers */ - void __iomem *base; - - /* whether a card is detected at the moment */ - int card_detected; - - /* type of detected card (mask of above enum) */ - u8 card_type; - - /* keep last socket status to implement event reporting */ - unsigned int old_status; - - /* backup of requested socket state */ - socket_state_t requested_state; - - /* timer used for socket status polling */ - struct timer_list timer; - - /* attribute/common memory resources */ - struct resource *attr_res; - struct resource *common_res; - struct resource *io_res; - - /* base address of io memory */ - void __iomem *io_base; -}; - -#endif /* BCM63XX_PCMCIA_H_ */ From patchwork Mon Feb 27 13:34:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13153495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 066D5C64ED8 for ; Mon, 27 Feb 2023 13:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KHtHYd9DW+83l07TqYF5dU4N3ppv7NEuTEDTSxgZQvg=; b=0JOBkZl19/BjVe 4tSzKU6K23r7tfoZTB4eIJ547kHKo7bLpTwXNCh54aV4wjJ4+TgyZGkPz0dDu7dILlinuWu6T89Yz TpIFwqODJHY4IIfaYnsXCN/NqNnScSbZHXzxVhu7BILeTAdQKPI+vZpMhuGtPawEMOxCx+djhwOuQ BwVUcaIhg8dibyL9XUp7tw6/CCHCeqqYUYTs8oUk1jjKsXqaObL005WpmpVkXir4D7VBIv+FLIs0L mPWalaAm56OCTcsTpyUTD450UFdloo62LQTpOo6/N6LsMhzdY6jb92UJmenJNe02/pnsP+oKocroR 9D948JB2K+sYOj2rgr+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfa-009mfa-Jk; Mon, 27 Feb 2023 13:35:58 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfB-009mUk-I6 for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2023 13:35:35 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2195360E8A; Mon, 27 Feb 2023 13:35:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2063C433EF; Mon, 27 Feb 2023 13:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677504932; bh=Zv8ORgdDsS7B5O2XiDMznU7S4fAx8H8PpVhPSwVfp3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IhtSdaR+FYSeTHkufcxyX4XvV21Ekd4UKn7a+Ntf7kHkAJUO1QzuuhPggAqrpk9LZ 9nb8XxqxdFWek3aBpHsvv/MyU5VNbsVCpq9kseca5txU5NmFk++qjGeVTsDWWPZ6hp jX/XLJxI1DdDTr9CuZPQTdJvyuwTZJEM/u03zPcsOEtAO2BYr0TxDQzM8mjtQ9MzBs ibye9Rpgv+z2lY754OsXm08xDblLU4Y2MZ6F6fWbtohXWM+yVxMqcTtW14WZ7qPbxu u8J4Vh3ah0SmZkeVTimt2kxH/fvbfpw7M+vJT0iqBBMR2vs1F/fXfGPNZzzWXJ3OVI dmtzLTFlwg7uA== From: Arnd Bergmann To: Dominik Brodowski , linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Bjorn Helgaas , Florian Fainelli , H Hartley Sweeten , Ian Abbott , Jakub Kicinski , Kevin Cernekee , Lukas Wunner , Manuel Lauss , Oliver Hartkopp , Olof Johansson , Robert Jarzmik , YOKOTA Hiroshi , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-mips@vger.kernel.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC 2/6] pccard: split cardbus support from pcmcia Date: Mon, 27 Feb 2023 14:34:53 +0100 Message-Id: <20230227133457.431729-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227133457.431729-1-arnd@kernel.org> References: <20230227133457.431729-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230227_053533_748752_1489DF01 X-CRM114-Status: GOOD ( 34.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann All pccard related technologies are obsolete, but there are a couple that are still used occasionally. Most importantly this includes 32-bit PCI/Cardbus devices on Laptop PCs built between 1997 and 2006 (Pentium MMX through Core Duo) and embedded systems using 16-bit PCMCIA/Compactflash slots for CF storage with the pata_pcmcia driver, but usually not the combination of the two. Separate the two configuration options for simplification and build the common code into both the pcmcia and cardbus layers, but only allow one of the two to be enabled in a kernel configuration, in order to allow further cleanups on top. This breaks the use of any 16-bit PCMCIA cards in a 32-bit capable cardbus slot. If anyone relies on support for this configuration and cannot use a cardbus compatible card instead, this should not be applied. In almost all cases, a cardbus or USB based card is superior and available cheaply compared to the older PCMCIA cards. In particular, CompactFlash cards now require an active card reader instead of a slow PCMCIA passthrough adapter. The CONFIG_PCMCIA option is now limited to platforms that actually shipped with PCMCIA or CF controllers, which is mostly x86 laptops from the i486 and Pentium eras as well as a couple of embedded systems. The Apple Powerbook is not included here, because all models with PCI support have Cardbus controllers and the earlier ones can not run Linux any more. Signed-off-by: Arnd Bergmann --- drivers/pcmcia/Kconfig | 13 +++++++----- drivers/pcmcia/Makefile | 10 ++++----- drivers/pcmcia/cardbus.c | 1 + drivers/pcmcia/cs.c | 25 +++++----------------- drivers/pcmcia/cs_internal.h | 1 + drivers/pcmcia/ds.c | 14 ++++++++++--- drivers/pcmcia/ricoh.h | 2 +- drivers/pcmcia/yenta_socket.c | 39 +++++++++++++++++++++++------------ include/pcmcia/ss.h | 4 ++-- 9 files changed, 60 insertions(+), 49 deletions(-) diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 26c89eefa18e..7b449d40da5e 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -21,6 +21,9 @@ if PCCARD config PCMCIA tristate "16-bit PCMCIA support" select CRC32 + depends on X86_32 || ARCH_PXA || ARCH_SA1100 || ARCH_OMAP1 || \ + MIPS_ALCHEMY || PPC_PASEMI || COMPILE_TEST + depends on CARDBUS=n default y help This option enables support for 16-bit PCMCIA cards. Most older @@ -51,8 +54,9 @@ config PCMCIA_LOAD_CIS If unsure, say Y. config CARDBUS - bool "32-bit CardBus support" + tristate "32-bit CardBus support" depends on PCI + select YENTA default y help CardBus is a bus mastering architecture for PC-cards, which allows @@ -71,10 +75,9 @@ config PCMCIA_MAX1600 comment "PC-card bridges" config YENTA - tristate "CardBus yenta-compatible bridge support" - depends on PCI - select CARDBUS if !EXPERT - select PCCARD_NONSTATIC if PCMCIA != n + tristate "CardBus yenta-compatible bridge support" if EXPERT + depends on PCI && CARDBUS + default y help This option enables support for CardBus host bridges. Virtually all modern PCMCIA bridges are CardBus compatible. A "bridge" is diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 67d447c62b8d..0f090543cefe 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -3,17 +3,17 @@ # Makefile for the kernel pcmcia subsystem (c/o David Hinds) # -pcmcia_core-y += cs.o socket_sysfs.o -pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o -obj-$(CONFIG_PCCARD) += pcmcia_core.o +cardbus_core-y += cardbus.o cs.o socket_sysfs.o rsrc_mgr.o +obj-$(CONFIG_CARDBUS) += cardbus_core.o -pcmcia-y += ds.o pcmcia_resource.o cistpl.o pcmcia_cis.o +pcmcia-y += ds.o pcmcia_resource.o cistpl.o pcmcia_cis.o \ + cs.o socket_sysfs.o obj-$(CONFIG_PCMCIA) += pcmcia.o pcmcia_rsrc-y += rsrc_mgr.o pcmcia_rsrc-$(CONFIG_PCCARD_NONSTATIC) += rsrc_nonstatic.o pcmcia_rsrc-$(CONFIG_PCCARD_IODYN) += rsrc_iodyn.o -obj-$(CONFIG_PCCARD) += pcmcia_rsrc.o +obj-$(CONFIG_PCMCIA) += pcmcia_rsrc.o # socket drivers diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 45c8252c8edc..2c5673ae58ba 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c @@ -121,4 +121,5 @@ void cb_free(struct pcmcia_socket *s) pci_stop_and_remove_bus_device(dev); pci_unlock_rescan_remove(); + } diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index e3224e49c43f..8ed89d7cfc94 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -133,7 +133,7 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) list_add_tail(&socket->socket_list, &pcmcia_socket_list); up_write(&pcmcia_socket_list_rwsem); -#ifndef CONFIG_CARDBUS +#if !IS_ENABLED(CONFIG_CARDBUS) /* * If we do not support Cardbus, ensure that * the Cardbus socket capability is disabled. @@ -313,7 +313,7 @@ static void socket_shutdown(struct pcmcia_socket *s) */ mutex_unlock(&s->ops_mutex); -#ifdef CONFIG_CARDBUS +#if IS_ENABLED(CONFIG_CARDBUS) cb_free(s); #endif @@ -428,7 +428,7 @@ static int socket_insert(struct pcmcia_socket *skt) (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", skt->sock); -#ifdef CONFIG_CARDBUS +#if IS_ENABLED(CONFIG_CARDBUS) if (skt->state & SOCKET_CARDBUS) { cb_alloc(skt); skt->state |= SOCKET_CARDBUS_CONFIG; @@ -522,7 +522,7 @@ static int socket_late_resume(struct pcmcia_socket *skt) static int socket_complete_resume(struct pcmcia_socket *skt) { int ret = 0; -#ifdef CONFIG_CARDBUS +#if IS_ENABLED(CONFIG_CARDBUS) if (skt->state & SOCKET_CARDBUS) { /* We can't be sure the CardBus card is the same * as the one previously inserted. Therefore, remove @@ -822,7 +822,7 @@ static int pcmcia_socket_uevent(const struct device *dev, } -static struct completion pcmcia_unload; +static DECLARE_COMPLETION(pcmcia_unload); static void pcmcia_release_socket_class(struct class *data) { @@ -901,18 +901,3 @@ struct class pcmcia_socket_class = { EXPORT_SYMBOL(pcmcia_socket_class); -static int __init init_pcmcia_cs(void) -{ - init_completion(&pcmcia_unload); - return class_register(&pcmcia_socket_class); -} - -static void __exit exit_pcmcia_cs(void) -{ - class_unregister(&pcmcia_socket_class); - wait_for_completion(&pcmcia_unload); -} - -subsys_initcall(init_pcmcia_cs); -module_exit(exit_pcmcia_cs); - diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 580369f3c0b0..1fc527fd06c3 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -18,6 +18,7 @@ #define _LINUX_CS_INTERNAL_H #include +#include /* Flags in client state */ #define CLIENT_WIN_REQ(i) (0x1<<(i)) diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index ace133b9f7d4..d68acd1ceabb 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -1419,9 +1419,16 @@ static int __init init_pcmcia_bus(void) { int ret; + ret = class_register(&pcmcia_socket_class); + if (ret < 0) { + printk(KERN_WARNING "pcmcia: class register error %d\n", ret); + return ret; + } + ret = bus_register(&pcmcia_bus_type); if (ret < 0) { printk(KERN_WARNING "pcmcia: bus_register error: %d\n", ret); + class_unregister(&pcmcia_socket_class); return ret; } ret = class_interface_register(&pcmcia_bus_interface); @@ -1429,20 +1436,21 @@ static int __init init_pcmcia_bus(void) printk(KERN_WARNING "pcmcia: class_interface_register error: %d\n", ret); bus_unregister(&pcmcia_bus_type); + class_unregister(&pcmcia_socket_class); return ret; } return 0; } -fs_initcall(init_pcmcia_bus); /* one level after subsys_initcall so that - * pcmcia_socket_class is already registered */ - +subsys_initcall(init_pcmcia_bus); static void __exit exit_pcmcia_bus(void) { class_interface_unregister(&pcmcia_bus_interface); bus_unregister(&pcmcia_bus_type); + + class_unregister(&pcmcia_socket_class); } module_exit(exit_pcmcia_bus); diff --git a/drivers/pcmcia/ricoh.h b/drivers/pcmcia/ricoh.h index 8ac7b138c094..bca3ebffb5c4 100644 --- a/drivers/pcmcia/ricoh.h +++ b/drivers/pcmcia/ricoh.h @@ -123,7 +123,7 @@ #define RL5C4XX_MISC3 0x00A2 /* 16 bit */ #define RL5C47X_MISC3_CB_CLKRUN_DIS BIT(1) -#ifdef __YENTA_H +#if IS_ENABLED(CONFIG_CARDBUS) #define rl_misc(socket) ((socket)->private[0]) #define rl_ctl(socket) ((socket)->private[1]) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 1365eaa20ff4..ac98d9bb8349 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -24,6 +24,7 @@ #include "yenta_socket.h" #include "i82365.h" +#include "cs_internal.h" static bool disable_clkrun; module_param(disable_clkrun, bool, 0444); @@ -228,17 +229,8 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value) val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT; val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0; } else if (state & CB_16BITCARD) { - u8 status = exca_readb(socket, I365_STATUS); - val |= ((status & I365_CS_DETECT) == I365_CS_DETECT) ? SS_DETECT : 0; - if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { - val |= (status & I365_CS_STSCHG) ? 0 : SS_STSCHG; - } else { - val |= (status & I365_CS_BVD1) ? 0 : SS_BATDEAD; - val |= (status & I365_CS_BVD2) ? 0 : SS_BATWARN; - } - val |= (status & I365_CS_WRPROT) ? SS_WRPROT : 0; - val |= (status & I365_CS_READY) ? SS_READY : 0; - val |= (status & I365_CS_POWERON) ? SS_POWERON : 0; + dev_warn_once(&socket->dev->dev, + "16-bit PCMCIA cards are no longer supported\n"); } *value = val; @@ -1176,7 +1168,7 @@ static int yenta_probe(struct pci_dev *dev, const struct pci_device_id *id) /* prepare pcmcia_socket */ socket->socket.ops = ¥ta_socket_operations; - socket->socket.resource_ops = &pccard_nonstatic_ops; + socket->socket.resource_ops = &pccard_static_ops; socket->socket.dev.parent = &dev->dev; socket->socket.driver_data = socket; socket->socket.owner = THIS_MODULE; @@ -1450,6 +1442,27 @@ static struct pci_driver yenta_cardbus_driver = { .driver.pm = YENTA_PM_OPS, }; -module_pci_driver(yenta_cardbus_driver); +static int __init yenta_init(void) +{ + int ret; + + ret = class_register(&pcmcia_socket_class); + if (ret) + return ret; + + ret = pci_register_driver(¥ta_cardbus_driver); + if (ret) + class_unregister(&pcmcia_socket_class); + + return ret; +} +module_init(yenta_init); + +static void __exit yenta_exit(void) +{ + pci_unregister_driver(¥ta_cardbus_driver); + class_unregister(&pcmcia_socket_class); +} +module_exit(yenta_exit); MODULE_LICENSE("GPL"); diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index 7cf7dbbfa131..b905f5248fc6 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -16,7 +16,7 @@ #include /* task_struct, completion */ #include -#ifdef CONFIG_CARDBUS +#if IS_ENABLED(CONFIG_CARDBUS) #include #endif @@ -176,7 +176,7 @@ struct pcmcia_socket { int (*power_hook)(struct pcmcia_socket *sock, int operation); /* allows tuning the CB bridge before loading driver for the CB card */ -#ifdef CONFIG_CARDBUS +#if IS_ENABLED(CONFIG_CARDBUS) void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus); #endif From patchwork Mon Feb 27 13:34:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13153496 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B037C64ED6 for ; Mon, 27 Feb 2023 13:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WTV9yQ2xrzurePxnY0LcuZ017O/R/KPBH9ADVGsgbIU=; b=EoMnkKoSRQrh1d yplXrPSK1Ifh8a9Dyg5DwHi4K7A5E92Df2s/a8q2o1pw8yabV3IFeq96YhiDeZH4YGqFiH75ZjJQe QFGZ/WBLSUCzOdbuDKcQ8E03HDfxTdDivCIhOrzGzwrzLQB2AuMalICyZpcmGTVG6IRK5e8ZLbYPy vMKPRHM2OLYfhbtWN0qzY7Wj05PBXBVej1g6zOzBn9GC/RBh/8Io9jRyIcxUIuV6UrUlC9W1Xr4Ni Qq9h2XUu07UFr3oQs6udHMm69gskEY95/P9GC0rnBjXGw9iHH9c2cS8l+AhhwGwtNqiPHe4/5D4Zn aWR7Kn+U9iuZ3x89GgkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfp-009ml0-7r; Mon, 27 Feb 2023 13:36:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfM-009mZ0-3r for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2023 13:35:49 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 80D9360E76; Mon, 27 Feb 2023 13:35:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DCB6C4339B; Mon, 27 Feb 2023 13:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677504942; bh=dcKzIljL/0MdmqIdum1Oso7FBUOVJFZs8Htgpn/H/y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HlmOF8hdJpfHCsmEqvwFfGIzhxHgTQLalqBvqj6oCdhpIRbynZTcMdzxRJYd/gvfT tDaWysRXTUqo9qSs65vVGnuE8wtBT9YEpiV5xzNEerxOO8lKJJGswF2FQ2l0HjQINe vaWM5ClCLaP4SUzOVu+TzjMYXGuTtwpcimJGZ9F9rdlX++pcZqsj67aEkE3OMDzK2+ uZ+Bj/FN8fbbg6+kwIZAzl1dWx35uNrOmAO0ooSNQpWXM1jL4I3mhhIEUmL8mqA1/v YlxO7m3HXD2YCtdta4LG2HYvH1lihI6M41tbpr9jCU0H22S7SyCa9xbTWacdcgZKxd r/e7vs//ujyoQ== From: Arnd Bergmann To: Dominik Brodowski , linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Bjorn Helgaas , Florian Fainelli , H Hartley Sweeten , Ian Abbott , Jakub Kicinski , Kevin Cernekee , Lukas Wunner , Manuel Lauss , Oliver Hartkopp , Olof Johansson , Robert Jarzmik , YOKOTA Hiroshi , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-mips@vger.kernel.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC 4/6] yenta_socket: remove dead code Date: Mon, 27 Feb 2023 14:34:55 +0100 Message-Id: <20230227133457.431729-5-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227133457.431729-1-arnd@kernel.org> References: <20230227133457.431729-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230227_053544_411217_E5B6B4D3 X-CRM114-Status: GOOD ( 31.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann A lot of the now merged pccard layer in the yenta_socket driver is never used on cardbus devices, so it can get removed. All global symbols can be made static and exports removed. The pccard_operations and pccard_resource_ops only have one valid implementation, so all indirect function pointers become direct calls. Signed-off-by: Arnd Bergmann --- drivers/pcmcia/yenta_socket.c | 955 ++++------------------------------ 1 file changed, 91 insertions(+), 864 deletions(-) diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index 64d11592bd99..68b852f18cbb 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -1,24 +1,40 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * ss.h + * Regular cardbus driver ("yenta_socket") * * The initial developer of the original code is David A. Hinds * . Portions created by David A. Hinds * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * (C) 1999 David A. Hinds + * (C) Copyright 1999, 2000 Linus Torvalds + * (C) 2003 - 2010 Dominik Brodowski + * */ - -#ifndef _LINUX_SS_H -#define _LINUX_SS_H - +#include #include -#include /* task_struct, completion */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include - -#if IS_ENABLED(CONFIG_CARDBUS) #include -#endif +#include +#include +#include +#include +#include +#include +#include +#include "i82365.h" /* Definitions for card status flags for GetStatus */ #define SS_WRPROT 0x0001 @@ -38,14 +54,6 @@ #define SS_PENDING 0x4000 #define SS_ZVCARD 0x8000 -/* InquireSocket capabilities */ -#define SS_CAP_PAGE_REGS 0x0001 -#define SS_CAP_VIRTUAL_BUS 0x0002 -#define SS_CAP_MEM_ALIGN 0x0004 -#define SS_CAP_STATIC_MAP 0x0008 -#define SS_CAP_PCCARD 0x4000 -#define SS_CAP_CARDBUS 0x8000 - /* for GetSocket, SetSocket */ typedef struct socket_state_t { u_int flags; @@ -54,8 +62,6 @@ typedef struct socket_state_t { u_char io_irq; } socket_state_t; -extern socket_state_t dead_socket; - /* Socket configuration flags */ #define SS_PWR_AUTO 0x0010 #define SS_IOCARD 0x0020 @@ -97,35 +103,12 @@ typedef struct pccard_mem_map { struct resource *res; } pccard_mem_map; -typedef struct io_window_t { - u_int InUse, Config; - struct resource *res; -} io_window_t; - -/* Maximum number of IO windows per socket */ -#define MAX_IO_WIN 2 - -/* Maximum number of memory windows per socket */ -#define MAX_WIN 4 - - -/* - * Socket operations. - */ struct pcmcia_socket; -struct pccard_resource_ops; -struct config_t; -struct pcmcia_callback; -struct user_info_t; - -struct pccard_operations { - int (*init)(struct pcmcia_socket *s); - int (*suspend)(struct pcmcia_socket *s); - int (*get_status)(struct pcmcia_socket *s, u_int *value); - int (*set_socket)(struct pcmcia_socket *s, socket_state_t *state); - int (*set_io_map)(struct pcmcia_socket *s, struct pccard_io_map *io); - int (*set_mem_map)(struct pcmcia_socket *s, struct pccard_mem_map *mem); -}; + +static int yenta_sock_init(struct pcmcia_socket *sock); +static int yenta_sock_suspend(struct pcmcia_socket *sock); +static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state); +static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value); struct pcmcia_socket { struct module *owner; @@ -133,16 +116,10 @@ struct pcmcia_socket { u_int state; u_int suspended_state; /* state before suspend */ u_short functions; - u_short lock_count; - pccard_mem_map cis_mem; - void __iomem *cis_virt; - io_window_t io[MAX_IO_WIN]; - pccard_mem_map win[MAX_WIN]; struct list_head cis_cache; size_t fake_cis_len; u8 *fake_cis; - struct list_head socket_list; struct completion socket_released; /* deprecated */ @@ -150,10 +127,7 @@ struct pcmcia_socket { /* socket capabilities */ - u_int features; u_int irq_mask; - u_int map_size; - u_int io_offset; u_int pci_irq; struct pci_dev *cb_dev; @@ -162,11 +136,6 @@ struct pcmcia_socket { * insertio events are actually managed by the PCMCIA layer.*/ u8 resource_setup_done; - /* socket operations */ - struct pccard_operations *ops; - struct pccard_resource_ops *resource_ops; - void *resource_data; - /* Zoom video behaviour is so chip specific its not worth adding this to _ops */ void (*zoom_video)(struct pcmcia_socket *, @@ -176,9 +145,7 @@ struct pcmcia_socket { int (*power_hook)(struct pcmcia_socket *sock, int operation); /* allows tuning the CB bridge before loading driver for the CB card */ -#if IS_ENABLED(CONFIG_CARDBUS) void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus); -#endif /* state thread */ struct task_struct *thread; @@ -194,73 +161,17 @@ struct pcmcia_socket { /* protects thread_events and sysfs_events */ spinlock_t thread_lock; - /* pcmcia (16-bit) */ - struct pcmcia_callback *callback; - -#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) - /* The following elements refer to 16-bit PCMCIA devices inserted - * into the socket */ - struct list_head devices_list; - - /* the number of devices, used only internally and subject to - * incorrectness and change */ - u8 device_count; - - /* does the PCMCIA card consist of two pseudo devices? */ - u8 pcmcia_pfc; - - /* non-zero if PCMCIA card is present */ - atomic_t present; - - /* IRQ to be used by PCMCIA devices. May not be IRQ 0. */ - unsigned int pcmcia_irq; - -#endif /* CONFIG_PCMCIA */ - /* socket device */ struct device dev; - /* data internal to the socket driver */ - void *driver_data; /* status of the card during resume from a system sleep state */ int resume_status; }; -/* socket drivers must define the resource operations type they use. There - * are three options: - * - pccard_static_ops iomem and ioport areas are assigned statically - * - pccard_iodyn_ops iomem areas is assigned statically, ioport - * areas dynamically - * If this option is selected, use - * "select PCCARD_IODYN" in Kconfig. - * - pccard_nonstatic_ops iomem and ioport areas are assigned dynamically. - * If this option is selected, use - * "select PCCARD_NONSTATIC" in Kconfig. - * - */ -extern struct pccard_resource_ops pccard_static_ops; -#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) -extern struct pccard_resource_ops pccard_iodyn_ops; -extern struct pccard_resource_ops pccard_nonstatic_ops; -#else -/* If PCMCIA is not used, but only CARDBUS, these functions are not used - * at all. Therefore, do not use the large (240K!) rsrc_nonstatic module - */ -#define pccard_iodyn_ops pccard_static_ops -#define pccard_nonstatic_ops pccard_static_ops -#endif - - /* socket drivers use this callback in their IRQ handler */ -extern void pcmcia_parse_events(struct pcmcia_socket *socket, +static void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events); -/* to register and unregister a socket */ -extern int pcmcia_register_socket(struct pcmcia_socket *socket); -extern void pcmcia_unregister_socket(struct pcmcia_socket *socket); - -#endif /* _LINUX_SS_H */ - #define CB_SOCKET_EVENT 0x00 #define CB_CSTSEVENT 0x00000001 /* Card status event */ #define CB_CD1EVENT 0x00000002 /* Card detect 1 change event */ @@ -358,7 +269,6 @@ extern void pcmcia_unregister_socket(struct pcmcia_socket *socket); #define YENTA_16BIT_POWER_EXCA 0x00000001 #define YENTA_16BIT_POWER_DF 0x00000002 - struct yenta_socket; struct cardbus_type { @@ -389,212 +299,28 @@ struct yenta_socket { u32 saved_state[2]; }; -/* - * cs_internal.h -- definitions internal to the PCMCIA core modules - * - * The initial developer of the original code is David A. Hinds - * . Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * (C) 1999 David A. Hinds - * (C) 2003 - 2010 Dominik Brodowski - * - * This file contains definitions _only_ needed by the PCMCIA core modules. - * It must not be included by PCMCIA socket drivers or by PCMCIA device - * drivers. - */ - -#ifndef _LINUX_CS_INTERNAL_H -#define _LINUX_CS_INTERNAL_H - -#include -#include - -/* Flags in client state */ -#define CLIENT_WIN_REQ(i) (0x1<<(i)) - -/* Flag to access all functions */ -#define BIND_FN_ALL 0xff - -/* Each card function gets one of these guys */ -typedef struct config_t { - struct kref ref; - unsigned int state; - - struct resource io[MAX_IO_WIN]; /* io ports */ - struct resource mem[MAX_WIN]; /* mem areas */ -} config_t; - - -struct cis_cache_entry { - struct list_head node; - unsigned int addr; - unsigned int len; - unsigned int attr; - unsigned char cache[]; -}; - -struct pccard_resource_ops { - int (*validate_mem) (struct pcmcia_socket *s); - int (*find_io) (struct pcmcia_socket *s, - unsigned int attr, - unsigned int *base, - unsigned int num, - unsigned int align, - struct resource **parent); - struct resource* (*find_mem) (unsigned long base, unsigned long num, - unsigned long align, int low, - struct pcmcia_socket *s); - int (*init) (struct pcmcia_socket *s); - void (*exit) (struct pcmcia_socket *s); -}; - -/* Flags in config state */ -#define CONFIG_LOCKED 0x01 -#define CONFIG_IRQ_REQ 0x02 -#define CONFIG_IO_REQ 0x04 +static int static_init(struct pcmcia_socket *s); /* Flags in socket state */ #define SOCKET_PRESENT 0x0008 #define SOCKET_INUSE 0x0010 #define SOCKET_IN_RESUME 0x0040 #define SOCKET_SUSPEND 0x0080 -#define SOCKET_WIN_REQ(i) (0x0100<<(i)) #define SOCKET_CARDBUS 0x8000 #define SOCKET_CARDBUS_CONFIG 0x10000 +static int pccard_sysfs_add_socket(struct device *dev); +static void pccard_sysfs_remove_socket(struct device *dev); +static int cb_alloc(struct pcmcia_socket *s); +static void cb_free(struct pcmcia_socket *s); +static struct class pcmcia_socket_class; -/* - * Stuff internal to module "pcmcia_rsrc": - */ -extern int static_init(struct pcmcia_socket *s); -extern struct resource *pcmcia_make_resource(resource_size_t start, - resource_size_t end, - unsigned long flags, const char *name); - -/* - * Stuff internal to module "pcmcia_core": - */ - -/* socket_sysfs.c */ -extern int pccard_sysfs_add_socket(struct device *dev); -extern void pccard_sysfs_remove_socket(struct device *dev); - -/* cardbus.c */ -int cb_alloc(struct pcmcia_socket *s); -void cb_free(struct pcmcia_socket *s); - - - -/* - * Stuff exported by module "pcmcia_core" to module "pcmcia" - */ - -struct pcmcia_callback{ - struct module *owner; - int (*add) (struct pcmcia_socket *s); - int (*remove) (struct pcmcia_socket *s); - void (*requery) (struct pcmcia_socket *s); - int (*validate) (struct pcmcia_socket *s, unsigned int *i); - int (*suspend) (struct pcmcia_socket *s); - int (*early_resume) (struct pcmcia_socket *s); - int (*resume) (struct pcmcia_socket *s); -}; - -/* cs.c */ -extern struct rw_semaphore pcmcia_socket_list_rwsem; -extern struct list_head pcmcia_socket_list; -extern struct class pcmcia_socket_class; - -int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); -struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); - -void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events); #define PCMCIA_UEVENT_EJECT 0x0001 #define PCMCIA_UEVENT_INSERT 0x0002 #define PCMCIA_UEVENT_SUSPEND 0x0004 #define PCMCIA_UEVENT_RESUME 0x0008 #define PCMCIA_UEVENT_REQUERY 0x0010 -struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt); -void pcmcia_put_socket(struct pcmcia_socket *skt); - -/* - * Stuff internal to module "pcmcia". - */ -/* ds.c */ -extern struct bus_type pcmcia_bus_type; - -struct pcmcia_device; - -/* pcmcia_resource.c */ -extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); -extern int pcmcia_validate_mem(struct pcmcia_socket *s); -extern struct resource *pcmcia_find_mem_region(u_long base, - u_long num, - u_long align, - int low, - struct pcmcia_socket *s); - -void pcmcia_cleanup_irq(struct pcmcia_socket *s); -int pcmcia_setup_irq(struct pcmcia_device *p_dev); - -/* cistpl.c */ -extern const struct bin_attribute pccard_cis_attr; - -int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, - u_int addr, u_int len, void *ptr); -int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, - u_int addr, u_int len, void *ptr); -void release_cis_mem(struct pcmcia_socket *s); -void destroy_cis_cache(struct pcmcia_socket *s); -int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, - cisdata_t code, void *parse); -int pcmcia_replace_cis(struct pcmcia_socket *s, - const u8 *data, const size_t len); -int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count); -int verify_cis_cache(struct pcmcia_socket *s); - -int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, - tuple_t *tuple); - -int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, - tuple_t *tuple); - -int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); - -#endif /* _LINUX_CS_INTERNAL_H */ -/* - * cs.c -- Kernel Card Services - core services - * - * The initial developer of the original code is David A. Hinds - * . Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * (C) 1999 David A. Hinds - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - /* Module parameters */ #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) @@ -611,37 +337,9 @@ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */ /* Access speed for attribute memory windows */ INT_MODULE_PARM(cis_speed, 300); /* ns */ - -socket_state_t dead_socket = { +static socket_state_t dead_socket = { .csc_mask = SS_DETECT, }; -EXPORT_SYMBOL(dead_socket); - - -/* List of all sockets, protected by a rwsem */ -LIST_HEAD(pcmcia_socket_list); -EXPORT_SYMBOL(pcmcia_socket_list); - -DECLARE_RWSEM(pcmcia_socket_list_rwsem); -EXPORT_SYMBOL(pcmcia_socket_list_rwsem); - - -struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt) -{ - struct device *dev = get_device(&skt->dev); - if (!dev) - return NULL; - return dev_get_drvdata(dev); -} -EXPORT_SYMBOL(pcmcia_get_socket); - - -void pcmcia_put_socket(struct pcmcia_socket *skt) -{ - put_device(&skt->dev); -} -EXPORT_SYMBOL(pcmcia_put_socket); - static void pcmcia_release_socket(struct device *dev) { @@ -656,56 +354,22 @@ static int pccardd(void *__skt); * pcmcia_register_socket - add a new pcmcia socket device * @socket: the &socket to register */ -int pcmcia_register_socket(struct pcmcia_socket *socket) +static int pcmcia_register_socket(struct pcmcia_socket *socket) { struct task_struct *tsk; + static atomic_t sock; int ret; - if (!socket || !socket->ops || !socket->dev.parent || !socket->resource_ops) + if (!socket || !socket->dev.parent) return -EINVAL; - dev_dbg(&socket->dev, "pcmcia_register_socket(0x%p)\n", socket->ops); - - /* try to obtain a socket number [yes, it gets ugly if we - * register more than 2^sizeof(unsigned int) pcmcia - * sockets... but the socket number is deprecated - * anyways, so I don't care] */ - down_write(&pcmcia_socket_list_rwsem); - if (list_empty(&pcmcia_socket_list)) - socket->sock = 0; - else { - unsigned int found, i = 1; - struct pcmcia_socket *tmp; - do { - found = 1; - list_for_each_entry(tmp, &pcmcia_socket_list, socket_list) { - if (tmp->sock == i) - found = 0; - } - i++; - } while (!found); - socket->sock = i - 1; - } - list_add_tail(&socket->socket_list, &pcmcia_socket_list); - up_write(&pcmcia_socket_list_rwsem); - -#if !IS_ENABLED(CONFIG_CARDBUS) - /* - * If we do not support Cardbus, ensure that - * the Cardbus socket capability is disabled. - */ - socket->features &= ~SS_CAP_CARDBUS; -#endif + socket->sock = atomic_fetch_inc(&sock); /* set proper values in socket->dev */ dev_set_drvdata(&socket->dev, socket); socket->dev.class = &pcmcia_socket_class; dev_set_name(&socket->dev, "pcmcia_socket%u", socket->sock); - /* base address = 0, map = 0 */ - socket->cis_mem.flags = 0; - socket->cis_mem.speed = cis_speed; - INIT_LIST_HEAD(&socket->cis_cache); init_completion(&socket->socket_released); @@ -714,13 +378,11 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) mutex_init(&socket->ops_mutex); spin_lock_init(&socket->thread_lock); - if (socket->resource_ops->init) { - mutex_lock(&socket->ops_mutex); - ret = socket->resource_ops->init(socket); - mutex_unlock(&socket->ops_mutex); - if (ret) - goto err; - } + mutex_lock(&socket->ops_mutex); + ret = static_init(socket); + mutex_unlock(&socket->ops_mutex); + if (ret) + goto err; tsk = kthread_run(pccardd, socket, "pccardd"); if (IS_ERR(tsk)) { @@ -747,60 +409,23 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) return 0; err: - down_write(&pcmcia_socket_list_rwsem); - list_del(&socket->socket_list); - up_write(&pcmcia_socket_list_rwsem); return ret; } /* pcmcia_register_socket */ -EXPORT_SYMBOL(pcmcia_register_socket); - /** * pcmcia_unregister_socket - remove a pcmcia socket device * @socket: the &socket to unregister */ -void pcmcia_unregister_socket(struct pcmcia_socket *socket) +static void pcmcia_unregister_socket(struct pcmcia_socket *socket) { if (!socket) return; - dev_dbg(&socket->dev, "pcmcia_unregister_socket(0x%p)\n", socket->ops); - if (socket->thread) kthread_stop(socket->thread); - /* remove from our own list */ - down_write(&pcmcia_socket_list_rwsem); - list_del(&socket->socket_list); - up_write(&pcmcia_socket_list_rwsem); - - /* wait for sysfs to drop all references */ - if (socket->resource_ops->exit) { - mutex_lock(&socket->ops_mutex); - socket->resource_ops->exit(socket); - mutex_unlock(&socket->ops_mutex); - } wait_for_completion(&socket->socket_released); } /* pcmcia_unregister_socket */ -EXPORT_SYMBOL(pcmcia_unregister_socket); - - -struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr) -{ - struct pcmcia_socket *s; - - down_read(&pcmcia_socket_list_rwsem); - list_for_each_entry(s, &pcmcia_socket_list, socket_list) - if (s->sock == nr) { - up_read(&pcmcia_socket_list_rwsem); - return s; - } - up_read(&pcmcia_socket_list_rwsem); - - return NULL; - -} -EXPORT_SYMBOL(pcmcia_get_socket_by_nr); static int socket_reset(struct pcmcia_socket *skt) { @@ -809,15 +434,15 @@ static int socket_reset(struct pcmcia_socket *skt) dev_dbg(&skt->dev, "reset\n"); skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET; - skt->ops->set_socket(skt, &skt->socket); + yenta_set_socket(skt, &skt->socket); udelay((long)reset_time); skt->socket.flags &= ~SS_RESET; - skt->ops->set_socket(skt, &skt->socket); + yenta_set_socket(skt, &skt->socket); msleep(unreset_delay * 10); for (i = 0; i < unreset_limit; i++) { - skt->ops->get_status(skt, &status); + yenta_get_status(skt, &status); if (!(status & SS_DETECT)) return -ENODEV; @@ -844,9 +469,6 @@ static void socket_shutdown(struct pcmcia_socket *s) dev_dbg(&s->dev, "shutdown\n"); - if (s->callback) - s->callback->remove(s); - mutex_lock(&s->ops_mutex); s->state &= SOCKET_INUSE | SOCKET_PRESENT; msleep(shutdown_delay * 10); @@ -854,9 +476,8 @@ static void socket_shutdown(struct pcmcia_socket *s) /* Blank out the socket state */ s->socket = dead_socket; - s->ops->init(s); - s->ops->set_socket(s, &s->socket); - s->lock_count = 0; + yenta_sock_init(s); + yenta_set_socket(s, &s->socket); kfree(s->fake_cis); s->fake_cis = NULL; s->functions = 0; @@ -869,14 +490,12 @@ static void socket_shutdown(struct pcmcia_socket *s) */ mutex_unlock(&s->ops_mutex); -#if IS_ENABLED(CONFIG_CARDBUS) cb_free(s); -#endif /* give socket some time to power down */ msleep(100); - s->ops->get_status(s, &status); + yenta_get_status(s, &status); if (status & SS_POWERON) { dev_err(&s->dev, "*** DANGER *** unable to remove socket power\n"); @@ -891,14 +510,14 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) dev_dbg(&skt->dev, "setup\n"); - skt->ops->get_status(skt, &status); + yenta_get_status(skt, &status); if (!(status & SS_DETECT)) return -ENODEV; msleep(initial_delay * 10); for (i = 0; i < 100; i++) { - skt->ops->get_status(skt, &status); + yenta_get_status(skt, &status); if (!(status & SS_DETECT)) return -ENODEV; @@ -914,10 +533,6 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) } if (status & SS_CARDBUS) { - if (!(skt->features & SS_CAP_CARDBUS)) { - dev_err(&skt->dev, "cardbus cards are not supported\n"); - return -EINVAL; - } skt->state |= SOCKET_CARDBUS; } else skt->state &= ~SOCKET_CARDBUS; @@ -938,14 +553,14 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) skt->power_hook(skt, HOOK_POWER_PRE); skt->socket.flags = 0; - skt->ops->set_socket(skt, &skt->socket); + yenta_set_socket(skt, &skt->socket); /* * Wait "vcc_settle" for the supply to stabilise. */ msleep(vcc_settle * 10); - skt->ops->get_status(skt, &status); + yenta_get_status(skt, &status); if (!(status & SS_POWERON)) { dev_err(&skt->dev, "unable to apply power\n"); return -EIO; @@ -984,17 +599,11 @@ static int socket_insert(struct pcmcia_socket *skt) (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", skt->sock); -#if IS_ENABLED(CONFIG_CARDBUS) - if (skt->state & SOCKET_CARDBUS) { - cb_alloc(skt); - skt->state |= SOCKET_CARDBUS_CONFIG; - } -#endif + cb_alloc(skt); + skt->state |= SOCKET_CARDBUS_CONFIG; + dev_dbg(&skt->dev, "insert done\n"); mutex_unlock(&skt->ops_mutex); - - if (!(skt->state & SOCKET_CARDBUS) && (skt->callback)) - skt->callback->add(skt); } else { mutex_unlock(&skt->ops_mutex); socket_shutdown(skt); @@ -1014,9 +623,8 @@ static int socket_suspend(struct pcmcia_socket *skt) skt->suspended_state = skt->state; skt->socket = dead_socket; - skt->ops->set_socket(skt, &skt->socket); - if (skt->ops->suspend) - skt->ops->suspend(skt); + yenta_set_socket(skt, &skt->socket); + yenta_sock_suspend(skt); skt->state |= SOCKET_SUSPEND; skt->state &= ~SOCKET_IN_RESUME; mutex_unlock(&skt->ops_mutex); @@ -1027,8 +635,8 @@ static int socket_early_resume(struct pcmcia_socket *skt) { mutex_lock(&skt->ops_mutex); skt->socket = dead_socket; - skt->ops->init(skt); - skt->ops->set_socket(skt, &skt->socket); + yenta_sock_init(skt); + yenta_set_socket(skt, &skt->socket); if (skt->state & SOCKET_PRESENT) skt->resume_status = socket_setup(skt, resume_delay); skt->state |= SOCKET_IN_RESUME; @@ -1065,8 +673,6 @@ static int socket_late_resume(struct pcmcia_socket *skt) return socket_insert(skt); } - if (!(skt->state & SOCKET_CARDBUS) && (skt->callback)) - ret = skt->callback->early_resume(skt); return ret; } @@ -1078,36 +684,16 @@ static int socket_late_resume(struct pcmcia_socket *skt) static int socket_complete_resume(struct pcmcia_socket *skt) { int ret = 0; -#if IS_ENABLED(CONFIG_CARDBUS) - if (skt->state & SOCKET_CARDBUS) { - /* We can't be sure the CardBus card is the same - * as the one previously inserted. Therefore, remove - * and re-add... */ - cb_free(skt); - ret = cb_alloc(skt); - if (ret) - cb_free(skt); - } -#endif - return ret; -} -/* - * Resume a socket. If a card is present, verify its CIS against - * our cached copy. If they are different, the card has been - * replaced, and we need to tell the drivers. - */ -static int socket_resume(struct pcmcia_socket *skt) -{ - int err; - if (!(skt->state & SOCKET_SUSPEND)) - return -EBUSY; + /* We can't be sure the CardBus card is the same + * as the one previously inserted. Therefore, remove + * and re-add... */ + cb_free(skt); + ret = cb_alloc(skt); + if (ret) + cb_free(skt); - socket_early_resume(skt); - err = socket_late_resume(skt); - if (!err) - err = socket_complete_resume(skt); - return err; + return ret; } static void socket_remove(struct pcmcia_socket *skt) @@ -1135,7 +721,7 @@ static void socket_detect_change(struct pcmcia_socket *skt) if (!(skt->state & SOCKET_PRESENT)) msleep(20); - skt->ops->get_status(skt, &status); + yenta_get_status(skt, &status); if ((skt->state & SOCKET_PRESENT) && !(status & SS_DETECT)) socket_remove(skt); @@ -1152,8 +738,8 @@ static int pccardd(void *__skt) skt->thread = current; skt->socket = dead_socket; - skt->ops->init(skt); - skt->ops->set_socket(skt, &skt->socket); + yenta_sock_init(skt); + yenta_set_socket(skt, &skt->socket); /* register with the device core */ ret = device_register(&skt->dev); @@ -1194,28 +780,6 @@ static int pccardd(void *__skt) socket_remove(skt); if (sysfs_events & PCMCIA_UEVENT_INSERT) socket_insert(skt); - if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) && - !(skt->state & SOCKET_CARDBUS)) { - if (skt->callback) - ret = skt->callback->suspend(skt); - else - ret = 0; - if (!ret) { - socket_suspend(skt); - msleep(100); - } - } - if ((sysfs_events & PCMCIA_UEVENT_RESUME) && - !(skt->state & SOCKET_CARDBUS)) { - ret = socket_resume(skt); - if (!ret && skt->callback) - skt->callback->resume(skt); - } - if ((sysfs_events & PCMCIA_UEVENT_REQUERY) && - !(skt->state & SOCKET_CARDBUS)) { - if (!ret && skt->callback) - skt->callback->requery(skt); - } } mutex_unlock(&skt->skt_mutex); @@ -1251,7 +815,7 @@ static int pccardd(void *__skt) * Yenta (at least) probes interrupts before registering the socket and * starting the handler thread. */ -void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) +static void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) { unsigned long flags; dev_dbg(&s->dev, "parse_events: events %08x\n", events); @@ -1263,7 +827,6 @@ void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) wake_up_process(s->thread); } } /* pcmcia_parse_events */ -EXPORT_SYMBOL(pcmcia_parse_events); /** * pcmcia_parse_uevents() - tell pccardd to issue manual commands @@ -1276,7 +839,7 @@ EXPORT_SYMBOL(pcmcia_parse_events); * PCMCIA_UEVENT_RESUME (for resume), PCMCIA_UEVENT_SUSPEND (for suspend) * and PCMCIA_UEVENT_REQUERY (for re-querying the PCMCIA card). */ -void pcmcia_parse_uevents(struct pcmcia_socket *s, u_int events) +static void pcmcia_parse_uevents(struct pcmcia_socket *s, u_int events) { unsigned long flags; dev_dbg(&s->dev, "parse_uevents: events %08x\n", events); @@ -1288,84 +851,12 @@ void pcmcia_parse_uevents(struct pcmcia_socket *s, u_int events) wake_up_process(s->thread); } } -EXPORT_SYMBOL(pcmcia_parse_uevents); - - -/* register pcmcia_callback */ -int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) -{ - int ret = 0; - - /* s->skt_mutex also protects s->callback */ - mutex_lock(&s->skt_mutex); - - if (c) { - /* registration */ - if (s->callback) { - ret = -EBUSY; - goto err; - } - - s->callback = c; - - if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) - s->callback->add(s); - } else - s->callback = NULL; - err: - mutex_unlock(&s->skt_mutex); - - return ret; -} -EXPORT_SYMBOL(pccard_register_pcmcia); - /* I'm not sure which "reset" function this is supposed to use, * but for now, it uses the low-level interface's reset, not the * CIS register. */ -int pcmcia_reset_card(struct pcmcia_socket *skt) -{ - int ret; - - dev_dbg(&skt->dev, "resetting socket\n"); - - mutex_lock(&skt->skt_mutex); - do { - if (!(skt->state & SOCKET_PRESENT)) { - dev_dbg(&skt->dev, "can't reset, not present\n"); - ret = -ENODEV; - break; - } - if (skt->state & SOCKET_SUSPEND) { - dev_dbg(&skt->dev, "can't reset, suspended\n"); - ret = -EBUSY; - break; - } - if (skt->state & SOCKET_CARDBUS) { - dev_dbg(&skt->dev, "can't reset, is cardbus\n"); - ret = -EPERM; - break; - } - - if (skt->callback) - skt->callback->suspend(skt); - mutex_lock(&skt->ops_mutex); - ret = socket_reset(skt); - mutex_unlock(&skt->ops_mutex); - if ((ret == 0) && (skt->callback)) - skt->callback->resume(skt); - - ret = 0; - } while (0); - mutex_unlock(&skt->skt_mutex); - - return ret; -} /* reset_card */ -EXPORT_SYMBOL(pcmcia_reset_card); - - static int pcmcia_socket_uevent(const struct device *dev, struct kobj_uevent_env *env) { @@ -1385,9 +876,6 @@ static void pcmcia_release_socket_class(struct class *data) complete(&pcmcia_unload); } - -#ifdef CONFIG_PM - static int __pcmcia_pm_op(struct device *dev, int (*callback) (struct pcmcia_socket *skt)) { @@ -1424,8 +912,7 @@ static void __used pcmcia_socket_dev_complete(struct device *dev) static const struct dev_pm_ops pcmcia_socket_pm_ops = { /* dev_resume may be called with IRQs enabled */ - SET_SYSTEM_SLEEP_PM_OPS(NULL, - pcmcia_socket_dev_resume) + SYSTEM_SLEEP_PM_OPS(NULL, pcmcia_socket_dev_resume) /* late suspend must be called with IRQs disabled */ .suspend_noirq = pcmcia_socket_dev_suspend_noirq, @@ -1439,49 +926,13 @@ static const struct dev_pm_ops pcmcia_socket_pm_ops = { .complete = pcmcia_socket_dev_complete, }; -#define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops) - -#else /* CONFIG_PM */ - -#define PCMCIA_SOCKET_CLASS_PM_OPS NULL - -#endif /* CONFIG_PM */ - -struct class pcmcia_socket_class = { +static struct class pcmcia_socket_class = { .name = "pcmcia_socket", .dev_uevent = pcmcia_socket_uevent, .dev_release = pcmcia_release_socket, .class_release = pcmcia_release_socket_class, - .pm = PCMCIA_SOCKET_CLASS_PM_OPS, + .pm = pm_ptr(&pcmcia_socket_pm_ops), }; -EXPORT_SYMBOL(pcmcia_socket_class); - -/* - * socket_sysfs.c -- most of socket-related sysfs output - * - * (C) 2003 - 2004 Dominik Brodowski - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include #define to_socket(_dev) container_of(_dev, struct pcmcia_socket, dev) @@ -1492,9 +943,7 @@ static ssize_t pccard_show_type(struct device *dev, struct device_attribute *att if (!(s->state & SOCKET_PRESENT)) return -ENODEV; - if (s->state & SOCKET_CARDBUS) - return sysfs_emit(buf, "32-bit\n"); - return sysfs_emit(buf, "16-bit\n"); + return sysfs_emit(buf, "32-bit\n"); } static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL); @@ -1672,43 +1121,16 @@ static const struct attribute_group socket_attrs = { .attrs = pccard_socket_attributes, }; -int pccard_sysfs_add_socket(struct device *dev) +static int pccard_sysfs_add_socket(struct device *dev) { return sysfs_create_group(&dev->kobj, &socket_attrs); } -void pccard_sysfs_remove_socket(struct device *dev) +static void pccard_sysfs_remove_socket(struct device *dev) { sysfs_remove_group(&dev->kobj, &socket_attrs); } -/* - * cardbus.c -- 16-bit PCMCIA core support - * - * The initial developer of the original code is David A. Hinds - * . Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * (C) 1999 David A. Hinds - */ - -/* - * Cardbus handling has been re-written to be more of a PCI bridge thing, - * and the PCI code basically does all the resource handling. - * - * Linus, Jan 2000 - */ - - -#include -#include -#include - -#include -#include - -#include "cs_internal.h" - static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq) { struct pci_dev *dev; @@ -1746,7 +1168,7 @@ static void cardbus_config_irq_and_cls(struct pci_bus *bus, int irq) * cb_alloc() allocates the kernel data structures for a Cardbus device * and handles the lowest level PCI device setup issues. */ -int __ref cb_alloc(struct pcmcia_socket *s) +static int __ref cb_alloc(struct pcmcia_socket *s) { struct pci_bus *bus = s->cb_dev->subordinate; struct pci_dev *dev; @@ -1785,7 +1207,7 @@ int __ref cb_alloc(struct pcmcia_socket *s) * * cb_free() handles the lowest level PCI device cleanup. */ -void cb_free(struct pcmcia_socket *s) +static void cb_free(struct pcmcia_socket *s) { struct pci_dev *bridge, *dev, *tmp; struct pci_bus *bus; @@ -1807,25 +1229,7 @@ void cb_free(struct pcmcia_socket *s) } -/* - * rsrc_mgr.c -- Resource management routines and/or wrappers - * - * The initial developer of the original code is David A. Hinds - * . Portions created by David A. Hinds - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. - * - * (C) 1999 David A. Hinds - */ - -#include -#include -#include - -#include -#include -#include "cs_internal.h" - -int static_init(struct pcmcia_socket *s) +static int static_init(struct pcmcia_socket *s) { /* the good thing about SS_CAP_STATIC_MAP sockets is * that they don't need a resource database */ @@ -1835,69 +1239,6 @@ int static_init(struct pcmcia_socket *s) return 0; } -struct resource *pcmcia_make_resource(resource_size_t start, - resource_size_t end, - unsigned long flags, const char *name) -{ - struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); - - if (res) { - res->name = name; - res->start = start; - res->end = start + end - 1; - res->flags = flags; - } - return res; -} - -static int static_find_io(struct pcmcia_socket *s, unsigned int attr, - unsigned int *base, unsigned int num, - unsigned int align, struct resource **parent) -{ - if (!s->io_offset) - return -EINVAL; - *base = s->io_offset | (*base & 0x0fff); - *parent = NULL; - - return 0; -} - -struct pccard_resource_ops pccard_static_ops = { - .validate_mem = NULL, - .find_io = static_find_io, - .find_mem = NULL, - .init = static_init, - .exit = NULL, -}; -EXPORT_SYMBOL(pccard_static_ops); - - -/* - * Regular cardbus driver ("yenta_socket") - * - * (C) Copyright 1999, 2000 Linus Torvalds - * - * Changelog: - * Aug 2002: Manfred Spraul - * Dynamically adjust the size of the bridge resource - * - * May 2003: Dominik Brodowski - * Merge pci_socket.c and yenta.c into one file - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "i82365.h" -#include "cs_internal.h" - static bool disable_clkrun; module_param(disable_clkrun, bool, 0444); MODULE_PARM_DESC(disable_clkrun, @@ -2111,59 +1452,8 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value) static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state) { - /* some birdges require to use the ExCA registers to power 16bit cards */ - if (!(cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) && - (socket->flags & YENTA_16BIT_POWER_EXCA)) { - u8 reg, old; - reg = old = exca_readb(socket, I365_POWER); - reg &= ~(I365_VCC_MASK | I365_VPP1_MASK | I365_VPP2_MASK); - - /* i82365SL-DF style */ - if (socket->flags & YENTA_16BIT_POWER_DF) { - switch (state->Vcc) { - case 33: - reg |= I365_VCC_3V; - break; - case 50: - reg |= I365_VCC_5V; - break; - default: - reg = 0; - break; - } - switch (state->Vpp) { - case 33: - case 50: - reg |= I365_VPP1_5V; - break; - case 120: - reg |= I365_VPP1_12V; - break; - } - } else { - /* i82365SL-B style */ - switch (state->Vcc) { - case 50: - reg |= I365_VCC_5V; - break; - default: - reg = 0; - break; - } - switch (state->Vpp) { - case 50: - reg |= I365_VPP1_5V | I365_VPP2_5V; - break; - case 120: - reg |= I365_VPP1_12V | I365_VPP2_12V; - break; - } - } - - if (reg != old) - exca_writeb(socket, I365_POWER, reg); - } else { - u32 reg = 0; /* CB_SC_STPCLK? */ + if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) { + u32 reg = 0; /* CB_SC_STPCLK? */ switch (state->Vcc) { case 33: reg = CB_SC_VCC_3V; @@ -2214,46 +1504,6 @@ static int yenta_set_socket(struct pcmcia_socket *sock, socket_state_t *state) bridge |= CB_BRIDGE_INTR; } exca_writeb(socket, I365_INTCTL, intr); - } else { - u8 reg; - - reg = exca_readb(socket, I365_INTCTL) & (I365_RING_ENA | I365_INTR_ENA); - reg |= (state->flags & SS_RESET) ? 0 : I365_PC_RESET; - reg |= (state->flags & SS_IOCARD) ? I365_PC_IOCARD : 0; - if (state->io_irq != socket->dev->irq) { - reg |= state->io_irq; - bridge |= CB_BRIDGE_INTR; - } - exca_writeb(socket, I365_INTCTL, reg); - - reg = exca_readb(socket, I365_POWER) & (I365_VCC_MASK|I365_VPP1_MASK); - reg |= I365_PWR_NORESET; - if (state->flags & SS_PWR_AUTO) - reg |= I365_PWR_AUTO; - if (state->flags & SS_OUTPUT_ENA) - reg |= I365_PWR_OUT; - if (exca_readb(socket, I365_POWER) != reg) - exca_writeb(socket, I365_POWER, reg); - - /* CSC interrupt: no ISA irq for CSC */ - reg = exca_readb(socket, I365_CSCINT); - reg &= I365_CSC_IRQ_MASK; - reg |= I365_CSC_DETECT; - if (state->flags & SS_IOCARD) { - if (state->csc_mask & SS_STSCHG) - reg |= I365_CSC_STSCHG; - } else { - if (state->csc_mask & SS_BATDEAD) - reg |= I365_CSC_BVD1; - if (state->csc_mask & SS_BATWARN) - reg |= I365_CSC_BVD2; - if (state->csc_mask & SS_READY) - reg |= I365_CSC_READY; - } - exca_writeb(socket, I365_CSCINT, reg); - exca_readb(socket, I365_CSC); - if (sock->zoom_video) - sock->zoom_video(sock, state->flags & SS_ZVCARD); } config_writew(socket, CB_BRIDGE_CONTROL, bridge); /* Socket event mask: get card insert/remove events.. */ @@ -2689,16 +1939,6 @@ static void yenta_close(struct pci_dev *dev) kfree(sock); } - -static struct pccard_operations yenta_socket_operations = { - .init = yenta_sock_init, - .suspend = yenta_sock_suspend, - .get_status = yenta_get_status, - .set_socket = yenta_set_socket, - .set_io_map = yenta_set_io_map, - .set_mem_map = yenta_set_mem_map, -}; - #ifdef CONFIG_YENTA_TI /* * ti113x.h 1.16 1999/10/25 20:03:34 @@ -4435,13 +3675,8 @@ static int yenta_probe(struct pci_dev *dev, const struct pci_device_id *id) return -ENOMEM; /* prepare pcmcia_socket */ - socket->socket.ops = ¥ta_socket_operations; - socket->socket.resource_ops = &pccard_static_ops; socket->socket.dev.parent = &dev->dev; - socket->socket.driver_data = socket; socket->socket.owner = THIS_MODULE; - socket->socket.features = SS_CAP_PAGE_REGS | SS_CAP_PCCARD; - socket->socket.map_size = 0x1000; socket->socket.cb_dev = dev; /* prepare struct yenta_socket */ @@ -4514,8 +3749,6 @@ static int yenta_probe(struct pci_dev *dev, const struct pci_device_id *id) "no PCI IRQ, CardBus support disabled for this socket.\n"); dev_info(&dev->dev, "check your BIOS CardBus, BIOS IRQ or ACPI settings.\n"); - } else { - socket->socket.features |= SS_CAP_CARDBUS; } /* Figure out what the dang thing can do for the PCMCIA layer... */ @@ -4559,7 +3792,6 @@ static int yenta_probe(struct pci_dev *dev, const struct pci_device_id *id) return ret; } -#ifdef CONFIG_PM_SLEEP static int yenta_dev_suspend_noirq(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); @@ -4604,14 +3836,9 @@ static int yenta_dev_resume_noirq(struct device *dev) } static const struct dev_pm_ops yenta_pm_ops = { - SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(yenta_dev_suspend_noirq, yenta_dev_resume_noirq) + NOIRQ_SYSTEM_SLEEP_PM_OPS(yenta_dev_suspend_noirq, yenta_dev_resume_noirq) }; -#define YENTA_PM_OPS (¥ta_pm_ops) -#else -#define YENTA_PM_OPS NULL -#endif - #define CB_ID(vend, dev, type) \ { \ .vendor = vend, \ @@ -4707,7 +3934,7 @@ static struct pci_driver yenta_cardbus_driver = { .id_table = yenta_table, .probe = yenta_probe, .remove = yenta_close, - .driver.pm = YENTA_PM_OPS, + .driver.pm = pm_sleep_ptr(¥ta_pm_ops), }; static int __init yenta_init(void) From patchwork Mon Feb 27 13:34:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13153497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA9B3C64ED8 for ; Mon, 27 Feb 2023 13:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GaNjUtL+HdmNjliUUOD7g5bXBhwJruKDmZp/43P841I=; b=VcCXBL0AAMfE9p zezbKqxGqDWZOVqtgdtvE8VK1H6sWYOS1G82Qw6QyVdYUfq556iao6tTpVeqzrRPKhh3gyUemhRKY 1Wsku2t98uAMWlPNyrdGW9Rspa8bFEm6gDgD17k3Yt+6HZoDqHx/HMAV5DPXJrhERgNbE2rREj1Vb /tU5LDJaKS8ARM3/qY5H58uEfyCyC++fTopsaO53XjXL9V7sPsUdO1slWg9o2VMLxT+tkY7xy4Cwk OLBvgBSjR/AoO6Uop8bTTJx7FTP9AI8xG5E2pNJKaZM7ci+dNLk6i1qe4X30HS9XBKtq2qHXFNrar 9t4rxYEnYuXfkVuCBmfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdg4-009mtR-Te; Mon, 27 Feb 2023 13:36:29 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfQ-009mbD-8a for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2023 13:35:51 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AAB5960E9B; Mon, 27 Feb 2023 13:35:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08801C433D2; Mon, 27 Feb 2023 13:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677504947; bh=1Ww/7e3RJTMKgfKFzXO3pKumxZIgKPNHR/yiafv3REY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PefI5B4VOrc57BLXksqw/xdqvSAUgtM6sxZtL3mr0qjuscydp9s1a67cbabzcDth+ iyHNv60VMjl1RHAuwyJKskyaXfSLO63e8SZvylsq1bp4upxupPyCJPzK/3JDUqXhL8 NUkN0eKIn5N2U8tKeEziLHfzaerHfhPQFL935z5/kbx6Flx/cSGKAn367Rnr+jfmSe gFHpS0GKXurz5t9E36Uob8Njclwq1yYknLWaygPSJtwo5ru2Ou5zjmfh7ACR5MOrmP cjPM8BB4mOwJuIZT2bbdNR8vz094/tfweersPYv54sJURWnT/idpGVUmY2udnV9bdG m7u/k9wWHeXjw== From: Arnd Bergmann To: Dominik Brodowski , linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Bjorn Helgaas , Florian Fainelli , H Hartley Sweeten , Ian Abbott , Jakub Kicinski , Kevin Cernekee , Lukas Wunner , Manuel Lauss , Oliver Hartkopp , Olof Johansson , Robert Jarzmik , YOKOTA Hiroshi , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-mips@vger.kernel.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC 5/6] pccard: drop remnants of cardbus support Date: Mon, 27 Feb 2023 14:34:56 +0100 Message-Id: <20230227133457.431729-6-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227133457.431729-1-arnd@kernel.org> References: <20230227133457.431729-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230227_053548_899111_88ED3288 X-CRM114-Status: GOOD ( 34.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Now that cardbus/yenta support is independent of PCMCIA support, there is no need to keep the conditional compilation bits around any longer. This means we can allow both CARDBUS and PCMCIA to be built as loadable modules, though actually loading them at the same time, or building them into the kernel would still fails because they try to create the same sysfs interface. Signed-off-by: Arnd Bergmann --- drivers/pcmcia/Kconfig | 2 +- drivers/pcmcia/cistpl.c | 10 +--- drivers/pcmcia/cs.c | 86 ++++------------------------------- drivers/pcmcia/cs_internal.h | 9 ---- drivers/pcmcia/socket_sysfs.c | 2 - include/pcmcia/ss.h | 21 --------- 6 files changed, 11 insertions(+), 119 deletions(-) diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 7b449d40da5e..c05d95cf7d3e 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -23,7 +23,7 @@ config PCMCIA select CRC32 depends on X86_32 || ARCH_PXA || ARCH_SA1100 || ARCH_OMAP1 || \ MIPS_ALCHEMY || PPC_PASEMI || COMPILE_TEST - depends on CARDBUS=n + depends on !CARDBUS default y help This option enables support for 16-bit PCMCIA cards. Most older diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 948b763dc451..05967953fafa 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -290,9 +290,6 @@ static int read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, struct cis_cache_entry *cis; int ret = 0; - if (s->state & SOCKET_CARDBUS) - return -EINVAL; - mutex_lock(&s->ops_mutex); if (s->fake_cis) { if (s->fake_cis_len >= addr+len) @@ -374,9 +371,6 @@ int verify_cis_cache(struct pcmcia_socket *s) char *buf; int ret; - if (s->state & SOCKET_CARDBUS) - return -EINVAL; - buf = kmalloc(256, GFP_KERNEL); if (buf == NULL) { dev_warn(&s->dev, "no memory for verifying CIS\n"); @@ -449,7 +443,7 @@ int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, if (!s) return -EINVAL; - if (!(s->state & SOCKET_PRESENT) || (s->state & SOCKET_CARDBUS)) + if (!(s->state & SOCKET_PRESENT)) return -ENODEV; tuple->TupleLink = tuple->Flags = 0; @@ -527,7 +521,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, if (!s) return -EINVAL; - if (!(s->state & SOCKET_PRESENT) || (s->state & SOCKET_CARDBUS)) + if (!(s->state & SOCKET_PRESENT)) return -ENODEV; link[1] = tuple->TupleLink; diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 8ed89d7cfc94..3d69914f5fec 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -133,14 +133,6 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) list_add_tail(&socket->socket_list, &pcmcia_socket_list); up_write(&pcmcia_socket_list_rwsem); -#if !IS_ENABLED(CONFIG_CARDBUS) - /* - * If we do not support Cardbus, ensure that - * the Cardbus socket capability is disabled. - */ - socket->features &= ~SS_CAP_CARDBUS; -#endif - /* set proper values in socket->dev */ dev_set_drvdata(&socket->dev, socket); socket->dev.class = &pcmcia_socket_class; @@ -313,10 +305,6 @@ static void socket_shutdown(struct pcmcia_socket *s) */ mutex_unlock(&s->ops_mutex); -#if IS_ENABLED(CONFIG_CARDBUS) - cb_free(s); -#endif - /* give socket some time to power down */ msleep(100); @@ -357,15 +345,6 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay) return -ETIMEDOUT; } - if (status & SS_CARDBUS) { - if (!(skt->features & SS_CAP_CARDBUS)) { - dev_err(&skt->dev, "cardbus cards are not supported\n"); - return -EINVAL; - } - skt->state |= SOCKET_CARDBUS; - } else - skt->state &= ~SOCKET_CARDBUS; - /* * Decode the card voltage requirements, and apply power to the card. */ @@ -425,19 +404,12 @@ static int socket_insert(struct pcmcia_socket *skt) skt->state |= SOCKET_PRESENT; dev_notice(&skt->dev, "pccard: %s card inserted into slot %d\n", - (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", - skt->sock); + "PCMCIA", skt->sock); -#if IS_ENABLED(CONFIG_CARDBUS) - if (skt->state & SOCKET_CARDBUS) { - cb_alloc(skt); - skt->state |= SOCKET_CARDBUS_CONFIG; - } -#endif dev_dbg(&skt->dev, "insert done\n"); mutex_unlock(&skt->ops_mutex); - if (!(skt->state & SOCKET_CARDBUS) && (skt->callback)) + if (skt->callback) skt->callback->add(skt); } else { mutex_unlock(&skt->ops_mutex); @@ -509,33 +481,11 @@ static int socket_late_resume(struct pcmcia_socket *skt) return socket_insert(skt); } - if (!(skt->state & SOCKET_CARDBUS) && (skt->callback)) + if (skt->callback) ret = skt->callback->early_resume(skt); return ret; } -/* - * Finalize the resume. In case of a cardbus socket, we have - * to rebind the devices as we can't be certain that it has been - * replaced, or not. - */ -static int socket_complete_resume(struct pcmcia_socket *skt) -{ - int ret = 0; -#if IS_ENABLED(CONFIG_CARDBUS) - if (skt->state & SOCKET_CARDBUS) { - /* We can't be sure the CardBus card is the same - * as the one previously inserted. Therefore, remove - * and re-add... */ - cb_free(skt); - ret = cb_alloc(skt); - if (ret) - cb_free(skt); - } -#endif - return ret; -} - /* * Resume a socket. If a card is present, verify its CIS against * our cached copy. If they are different, the card has been @@ -543,15 +493,11 @@ static int socket_complete_resume(struct pcmcia_socket *skt) */ static int socket_resume(struct pcmcia_socket *skt) { - int err; if (!(skt->state & SOCKET_SUSPEND)) return -EBUSY; socket_early_resume(skt); - err = socket_late_resume(skt); - if (!err) - err = socket_complete_resume(skt); - return err; + return socket_late_resume(skt); } static void socket_remove(struct pcmcia_socket *skt) @@ -638,8 +584,7 @@ static int pccardd(void *__skt) socket_remove(skt); if (sysfs_events & PCMCIA_UEVENT_INSERT) socket_insert(skt); - if ((sysfs_events & PCMCIA_UEVENT_SUSPEND) && - !(skt->state & SOCKET_CARDBUS)) { + if (sysfs_events & PCMCIA_UEVENT_SUSPEND) { if (skt->callback) ret = skt->callback->suspend(skt); else @@ -649,14 +594,12 @@ static int pccardd(void *__skt) msleep(100); } } - if ((sysfs_events & PCMCIA_UEVENT_RESUME) && - !(skt->state & SOCKET_CARDBUS)) { + if (sysfs_events & PCMCIA_UEVENT_RESUME) { ret = socket_resume(skt); if (!ret && skt->callback) skt->callback->resume(skt); } - if ((sysfs_events & PCMCIA_UEVENT_REQUERY) && - !(skt->state & SOCKET_CARDBUS)) { + if (sysfs_events & PCMCIA_UEVENT_REQUERY) { if (!ret && skt->callback) skt->callback->requery(skt); } @@ -752,7 +695,7 @@ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) s->callback = c; - if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) + if (s->state & SOCKET_PRESENT) s->callback->add(s); } else s->callback = NULL; @@ -787,12 +730,6 @@ int pcmcia_reset_card(struct pcmcia_socket *skt) ret = -EBUSY; break; } - if (skt->state & SOCKET_CARDBUS) { - dev_dbg(&skt->dev, "can't reset, is cardbus\n"); - ret = -EPERM; - break; - } - if (skt->callback) skt->callback->suspend(skt); mutex_lock(&skt->ops_mutex); @@ -860,12 +797,6 @@ static int __used pcmcia_socket_dev_resume(struct device *dev) return __pcmcia_pm_op(dev, socket_late_resume); } -static void __used pcmcia_socket_dev_complete(struct device *dev) -{ - WARN(__pcmcia_pm_op(dev, socket_complete_resume), - "failed to complete resume"); -} - static const struct dev_pm_ops pcmcia_socket_pm_ops = { /* dev_resume may be called with IRQs enabled */ SET_SYSTEM_SLEEP_PM_OPS(NULL, @@ -880,7 +811,6 @@ static const struct dev_pm_ops pcmcia_socket_pm_ops = { .resume_noirq = pcmcia_socket_dev_resume_noirq, .thaw_noirq = pcmcia_socket_dev_resume_noirq, .restore_noirq = pcmcia_socket_dev_resume_noirq, - .complete = pcmcia_socket_dev_complete, }; #define PCMCIA_SOCKET_CLASS_PM_OPS (&pcmcia_socket_pm_ops) diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 1fc527fd06c3..c29b86d6910b 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -70,9 +70,6 @@ struct pccard_resource_ops { #define SOCKET_IN_RESUME 0x0040 #define SOCKET_SUSPEND 0x0080 #define SOCKET_WIN_REQ(i) (0x0100<<(i)) -#define SOCKET_CARDBUS 0x8000 -#define SOCKET_CARDBUS_CONFIG 0x10000 - /* * Stuff internal to module "pcmcia_rsrc": @@ -90,12 +87,6 @@ extern struct resource *pcmcia_make_resource(resource_size_t start, extern int pccard_sysfs_add_socket(struct device *dev); extern void pccard_sysfs_remove_socket(struct device *dev); -/* cardbus.c */ -int cb_alloc(struct pcmcia_socket *s); -void cb_free(struct pcmcia_socket *s); - - - /* * Stuff exported by module "pcmcia_core" to module "pcmcia" */ diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index c7a906664c36..d41d6fbe48cf 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -37,8 +37,6 @@ static ssize_t pccard_show_type(struct device *dev, struct device_attribute *att if (!(s->state & SOCKET_PRESENT)) return -ENODEV; - if (s->state & SOCKET_CARDBUS) - return sysfs_emit(buf, "32-bit\n"); return sysfs_emit(buf, "16-bit\n"); } static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL); diff --git a/include/pcmcia/ss.h b/include/pcmcia/ss.h index b905f5248fc6..ea22367e6a78 100644 --- a/include/pcmcia/ss.h +++ b/include/pcmcia/ss.h @@ -16,10 +16,6 @@ #include /* task_struct, completion */ #include -#if IS_ENABLED(CONFIG_CARDBUS) -#include -#endif - /* Definitions for card status flags for GetStatus */ #define SS_WRPROT 0x0001 #define SS_CARDLOCK 0x0002 @@ -175,11 +171,6 @@ struct pcmcia_socket { /* so is power hook */ int (*power_hook)(struct pcmcia_socket *sock, int operation); - /* allows tuning the CB bridge before loading driver for the CB card */ -#if IS_ENABLED(CONFIG_CARDBUS) - void (*tune_bridge)(struct pcmcia_socket *sock, struct pci_bus *bus); -#endif - /* state thread */ struct task_struct *thread; struct completion thread_done; @@ -197,7 +188,6 @@ struct pcmcia_socket { /* pcmcia (16-bit) */ struct pcmcia_callback *callback; -#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) /* The following elements refer to 16-bit PCMCIA devices inserted * into the socket */ struct list_head devices_list; @@ -215,8 +205,6 @@ struct pcmcia_socket { /* IRQ to be used by PCMCIA devices. May not be IRQ 0. */ unsigned int pcmcia_irq; -#endif /* CONFIG_PCMCIA */ - /* socket device */ struct device dev; /* data internal to the socket driver */ @@ -239,17 +227,8 @@ struct pcmcia_socket { * */ extern struct pccard_resource_ops pccard_static_ops; -#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) extern struct pccard_resource_ops pccard_iodyn_ops; extern struct pccard_resource_ops pccard_nonstatic_ops; -#else -/* If PCMCIA is not used, but only CARDBUS, these functions are not used - * at all. Therefore, do not use the large (240K!) rsrc_nonstatic module - */ -#define pccard_iodyn_ops pccard_static_ops -#define pccard_nonstatic_ops pccard_static_ops -#endif - /* socket drivers use this callback in their IRQ handler */ extern void pcmcia_parse_events(struct pcmcia_socket *socket, From patchwork Mon Feb 27 13:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13153498 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87515C64ED8 for ; Mon, 27 Feb 2023 13:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ey5QczXDCzZnxFsYVxGzH123CcaoTd/iyp+897lB3UA=; b=zdDExNI5ey9dd+ +2EvbhBGrzTVEqi1PWL1T5ZUiysuLrIfoxc1x4k6sFbRB1v8N8RAKyPz6dHjdEJg4MjOGWno7t6yA GitMShYaZ8w7orNFXlSZE/H4Em1Rxt/NIfrN1JZmlu/clUgZtt0zlz3VgENErU5ZrxHP01b7SIzuG vmiTnK1jTtBf9b2qw9NFe2nDkabh68b3E7HSCsIduhM0oUBgjwJtXvtZdIbVSAWIyXv3qm2athgpN CdHyS+HyZTVGpizqF/52Q0IXjO33AhkRzrp7v+Ln7XpCfWFfltjL8H6WCAoG2y+1otVDrHnqtWWhJ QE7EZQXanwPvtH/l8AiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdgK-009n0r-IB; Mon, 27 Feb 2023 13:36:44 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pWdfV-009me4-EG for linux-arm-kernel@lists.infradead.org; Mon, 27 Feb 2023 13:35:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F22760C8C; Mon, 27 Feb 2023 13:35:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EAB1AC433EF; Mon, 27 Feb 2023 13:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677504952; bh=b9HrZOsZ0t1HTiFoX7ydm1tiygWOLP83zg9nAfNZ1yw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pB5p/z8zHfkoobffWNCngXWOTxAEZxBf8BJR8ukTfFakmvaT5brl++TVnvCgLnqIz V0a0lbAKirRTFwqbTgUxIP99kEN36fP+v0w9leayMeqi+KDLnroY1rZksb3nEVpb4g Txoj5inxcnxhRcYF03mzK249tBVstnL+txTarvCp4Sy9PXCvWC1oPUim1+wN8Y0IRf HtBQ/EGSN6EfeCBudpB+caa4CLl1GiC1lVDXF3Qq0jCLsq4lncEjos3fm1d8raTQQI hWrD1dAyO5UtKEbMJ5xYXM4Wsnbp/VxPZLisb/EABgdhUgIZHG+0iX3kYie1AVkM5C fjp00cc2uzyPw== From: Arnd Bergmann To: Dominik Brodowski , linux-kernel@vger.kernel.org Cc: Arnd Bergmann , Bjorn Helgaas , Florian Fainelli , H Hartley Sweeten , Ian Abbott , Jakub Kicinski , Kevin Cernekee , Lukas Wunner , Manuel Lauss , Oliver Hartkopp , Olof Johansson , Robert Jarzmik , YOKOTA Hiroshi , bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-can@vger.kernel.org, linux-mips@vger.kernel.org, linux-pci@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC 6/6] pci: hotplug: move cardbus code from drivers/pcmcia Date: Mon, 27 Feb 2023 14:34:57 +0100 Message-Id: <20230227133457.431729-7-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230227133457.431729-1-arnd@kernel.org> References: <20230227133457.431729-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230227_053553_608009_CB4CEC71 X-CRM114-Status: GOOD ( 19.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann 16-bit pcmcia and 32-bit cardbus code are now completely separate code bases, with the cardbus implementation just interfacig with the PCI core for hotplugging cards, so move it to the same place as the other PCI hotplug drivers. The pcmcia/i82365.h header file is the only bit that contains shared definitions for common registers. Signed-off-by: Arnd Bergmann --- drivers/Makefile | 2 +- drivers/pci/hotplug/Kconfig | 56 +++++++++++++++++++ drivers/pci/hotplug/Makefile | 1 + .../{pcmcia => pci/hotplug}/yenta_socket.c | 2 +- drivers/pcmcia/Kconfig | 56 ------------------- drivers/pcmcia/Makefile | 3 - drivers/pcmcia/i82092.c | 2 +- drivers/pcmcia/i82365.c | 2 +- drivers/pcmcia/pd6729.c | 3 +- {drivers => include}/pcmcia/i82365.h | 0 10 files changed, 62 insertions(+), 65 deletions(-) rename drivers/{pcmcia => pci/hotplug}/yenta_socket.c (99%) rename {drivers => include}/pcmcia/i82365.h (100%) diff --git a/drivers/Makefile b/drivers/Makefile index bdf1c66141c9..900a37a1b401 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -93,7 +93,7 @@ obj-$(CONFIG_UIO) += uio/ obj-$(CONFIG_VFIO) += vfio/ obj-y += cdrom/ obj-y += auxdisplay/ -obj-$(CONFIG_PCCARD) += pcmcia/ +obj-$(CONFIG_PCMCIA) += pcmcia/ obj-$(CONFIG_DIO) += dio/ obj-$(CONFIG_SBUS) += sbus/ obj-$(CONFIG_ZORRO) += zorro/ diff --git a/drivers/pci/hotplug/Kconfig b/drivers/pci/hotplug/Kconfig index 48113b210cf9..83941cb45291 100644 --- a/drivers/pci/hotplug/Kconfig +++ b/drivers/pci/hotplug/Kconfig @@ -161,4 +161,60 @@ config HOTPLUG_PCI_S390 When in doubt, say Y. +config CARDBUS + tristate "32-bit CardBus support" + depends on PCI + select YENTA + default PCCARD + help + CardBus is a bus mastering architecture for PC-cards, which allows + for 32 bit PC-cards (the original PCMCIA standard specifies only + a 16 bit wide bus). Many newer PC-cards are actually CardBus cards. + + To use 32 bit PC-cards, you also need a CardBus compatible host + bridge. Virtually all modern PCMCIA bridges do this, and most of + them are "yenta-compatible", so say Y or M there, too. + + If unsure, say Y. + +config YENTA + tristate "CardBus yenta-compatible bridge support" if EXPERT + depends on PCI && CARDBUS + default y + help + This option enables support for CardBus host bridges. Virtually + all modern PCMCIA bridges are CardBus compatible. A "bridge" is + the hardware inside your computer that PCMCIA cards are plugged + into. + + To compile this driver as modules, choose M here: the + module will be called yenta_socket. + + If unsure, say Y. + +config YENTA_O2 + default y + bool "Special initialization for O2Micro bridges" if EXPERT + depends on YENTA + +config YENTA_RICOH + default y + bool "Special initialization for Ricoh bridges" if EXPERT + depends on YENTA + +config YENTA_TI + default y + bool "Special initialization for TI and EnE bridges" if EXPERT + depends on YENTA + +config YENTA_ENE_TUNE + default y + bool "Auto-tune EnE bridges for CB cards" if EXPERT + depends on YENTA_TI && CARDBUS + +config YENTA_TOSHIBA + default y + bool "Special initialization for Toshiba ToPIC bridges" if EXPERT + depends on YENTA + endif # HOTPLUG_PCI diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile index 5196983220df..8b655c283565 100644 --- a/drivers/pci/hotplug/Makefile +++ b/drivers/pci/hotplug/Makefile @@ -20,6 +20,7 @@ obj-$(CONFIG_HOTPLUG_PCI_RPA) += rpaphp.o obj-$(CONFIG_HOTPLUG_PCI_RPA_DLPAR) += rpadlpar_io.o obj-$(CONFIG_HOTPLUG_PCI_ACPI) += acpiphp.o obj-$(CONFIG_HOTPLUG_PCI_S390) += s390_pci_hpc.o +obj-$(CONFIG_CARDBUS) += yenta_socket.o # acpiphp_ibm extends acpiphp, so should be linked afterwards. diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pci/hotplug/yenta_socket.c similarity index 99% rename from drivers/pcmcia/yenta_socket.c rename to drivers/pci/hotplug/yenta_socket.c index 68b852f18cbb..3b530ce76809 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pci/hotplug/yenta_socket.c @@ -34,7 +34,7 @@ #include #include #include -#include "i82365.h" +#include /* Definitions for card status flags for GetStatus */ #define SS_WRPROT 0x0001 diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index c05d95cf7d3e..3c4b895dba80 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -53,67 +53,11 @@ config PCMCIA_LOAD_CIS If unsure, say Y. -config CARDBUS - tristate "32-bit CardBus support" - depends on PCI - select YENTA - default y - help - CardBus is a bus mastering architecture for PC-cards, which allows - for 32 bit PC-cards (the original PCMCIA standard specifies only - a 16 bit wide bus). Many newer PC-cards are actually CardBus cards. - - To use 32 bit PC-cards, you also need a CardBus compatible host - bridge. Virtually all modern PCMCIA bridges do this, and most of - them are "yenta-compatible", so say Y or M there, too. - - If unsure, say Y. - config PCMCIA_MAX1600 tristate comment "PC-card bridges" -config YENTA - tristate "CardBus yenta-compatible bridge support" if EXPERT - depends on PCI && CARDBUS - default y - help - This option enables support for CardBus host bridges. Virtually - all modern PCMCIA bridges are CardBus compatible. A "bridge" is - the hardware inside your computer that PCMCIA cards are plugged - into. - - To compile this driver as modules, choose M here: the - module will be called yenta_socket. - - If unsure, say Y. - -config YENTA_O2 - default y - bool "Special initialization for O2Micro bridges" if EXPERT - depends on YENTA - -config YENTA_RICOH - default y - bool "Special initialization for Ricoh bridges" if EXPERT - depends on YENTA - -config YENTA_TI - default y - bool "Special initialization for TI and EnE bridges" if EXPERT - depends on YENTA - -config YENTA_ENE_TUNE - default y - bool "Auto-tune EnE bridges for CB cards" if EXPERT - depends on YENTA_TI && CARDBUS - -config YENTA_TOSHIBA - default y - bool "Special initialization for Toshiba ToPIC bridges" if EXPERT - depends on YENTA - config PD6729 tristate "Cirrus PD6729 compatible bridge support" depends on PCMCIA && PCI diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 4d0af3e27c1c..481468778f46 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -14,9 +14,6 @@ obj-$(CONFIG_PCMCIA) += pcmcia_rsrc.o # socket drivers - -obj-$(CONFIG_YENTA) += yenta_socket.o - obj-$(CONFIG_PD6729) += pd6729.o obj-$(CONFIG_I82365) += i82365.o obj-$(CONFIG_I82092) += i82092.o diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c index a335748bdef5..b74eb77e7489 100644 --- a/drivers/pcmcia/i82092.c +++ b/drivers/pcmcia/i82092.c @@ -17,11 +17,11 @@ #include #include +#include #include #include "i82092aa.h" -#include "i82365.h" MODULE_LICENSE("GPL"); diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 891ccea2cccb..bb4045b4613a 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -54,7 +54,7 @@ #include /* ISA-bus controllers */ -#include "i82365.h" +#include #include "cirrus.h" #include "vg468.h" #include "ricoh.h" diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c index a0a2e7f18356..ec8c093e7fd0 100644 --- a/drivers/pcmcia/pd6729.c +++ b/drivers/pcmcia/pd6729.c @@ -18,10 +18,9 @@ #include #include - +#include #include "pd6729.h" -#include "i82365.h" #include "cirrus.h" MODULE_LICENSE("GPL"); diff --git a/drivers/pcmcia/i82365.h b/include/pcmcia/i82365.h similarity index 100% rename from drivers/pcmcia/i82365.h rename to include/pcmcia/i82365.h