From patchwork Fri Jan 13 06:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644798 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ABC2C678D9 for ; Fri, 13 Jan 2023 06:25:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238365AbjAMGZf (ORCPT ); Fri, 13 Jan 2023 01:25:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239005AbjAMGYb (ORCPT ); Fri, 13 Jan 2023 01:24:31 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E0669B33; Thu, 12 Jan 2023 22:24:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=YWdaNZZD6eiGGHiQwqB4d/n7vbdllZAZ4PVlQ9KrUog=; b=XtPGvVCciAHH/ZLi442ryHF6rq FvgKnRpeqvwCx9UPgqvxyoSez2P7/TsQH4CCdKmAVKMjtEs7KN5fhRpLHTjMdmTb4fMzzf6CmNKlf rXdbPlEScIlBvjJrEpLQ9Qz+cT5QX9vrjKWKFTMLmEzur4VlSN6Xl4jhStM3ZSCwOvwfNkCRTuNnR wJyIbeNnp1Bzl3/RFdCiY+e0gUrTlrvJFtmxx0gpbmv+sIP/JUZGEtJIDk593yDFSk9RClQJfmg7Y 4kjnLNtrXGl9NJsEFRSHVUmWUakVHMHmyXzQxjKYElq0QLSA3Qcs/NoVXvf4FXw2zlWkEQ7IFJk43 R2e+Go7Q==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDTr-000lRy-FI; Fri, 13 Jan 2023 06:24:00 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 04/22] sound: remove sound/sh Date: Fri, 13 Jan 2023 07:23:21 +0100 Message-Id: <20230113062339.1909087-5-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed these drivers are dead code. Signed-off-by: Christoph Hellwig --- sound/Kconfig | 2 - sound/Makefile | 2 +- sound/sh/Kconfig | 32 -- sound/sh/Makefile | 11 - sound/sh/aica.c | 628 ---------------------------------------- sound/sh/aica.h | 68 ----- sound/sh/sh_dac_audio.c | 412 -------------------------- 7 files changed, 1 insertion(+), 1154 deletions(-) delete mode 100644 sound/sh/Kconfig delete mode 100644 sound/sh/Makefile delete mode 100644 sound/sh/aica.c delete mode 100644 sound/sh/aica.h delete mode 100644 sound/sh/sh_dac_audio.c diff --git a/sound/Kconfig b/sound/Kconfig index e56d96d2b11cae..14361bb428baa1 100644 --- a/sound/Kconfig +++ b/sound/Kconfig @@ -75,8 +75,6 @@ source "sound/spi/Kconfig" source "sound/mips/Kconfig" -source "sound/sh/Kconfig" - # the following will depend on the order of config. # here assuming USB is defined before ALSA source "sound/usb/Kconfig" diff --git a/sound/Makefile b/sound/Makefile index 04ef04b1168f39..bb4b8806321c67 100644 --- a/sound/Makefile +++ b/sound/Makefile @@ -4,7 +4,7 @@ obj-$(CONFIG_SOUND) += soundcore.o obj-$(CONFIG_DMASOUND) += oss/dmasound/ -obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ sh/ synth/ usb/ \ +obj-$(CONFIG_SND) += core/ i2c/ drivers/ isa/ pci/ ppc/ arm/ synth/ usb/ \ firewire/ sparc/ spi/ parisc/ pcmcia/ mips/ soc/ atmel/ hda/ x86/ xen/ \ virtio/ obj-$(CONFIG_SND_AOA) += aoa/ diff --git a/sound/sh/Kconfig b/sound/sh/Kconfig deleted file mode 100644 index b75fbb3236a7b9..00000000000000 --- a/sound/sh/Kconfig +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# ALSA SH drivers - -menuconfig SND_SUPERH - bool "SUPERH sound devices" - depends on SUPERH - default y - help - Support for sound devices specific to SUPERH architectures. - Drivers that are implemented on ASoC can be found in - "ALSA for SoC audio support" section. - -if SND_SUPERH - -config SND_AICA - tristate "Dreamcast Yamaha AICA sound" - depends on SH_DREAMCAST - select SND_PCM - select G2_DMA - help - ALSA Sound driver for the SEGA Dreamcast console. - -config SND_SH_DAC_AUDIO - tristate "SuperH DAC audio support" - depends on SND - depends on CPU_SH3 && HIGH_RES_TIMERS - select SND_PCM - help - Say Y here to include support for the on-chip DAC. - -endif # SND_SUPERH - diff --git a/sound/sh/Makefile b/sound/sh/Makefile deleted file mode 100644 index c0bbc500c17c73..00000000000000 --- a/sound/sh/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# Makefile for ALSA -# - -snd-aica-objs := aica.o -snd-sh_dac_audio-objs := sh_dac_audio.o - -# Toplevel Module Dependency -obj-$(CONFIG_SND_AICA) += snd-aica.o -obj-$(CONFIG_SND_SH_DAC_AUDIO) += snd-sh_dac_audio.o diff --git a/sound/sh/aica.c b/sound/sh/aica.c deleted file mode 100644 index 6e9d6bd67369af..00000000000000 --- a/sound/sh/aica.c +++ /dev/null @@ -1,628 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* -* Copyright Adrian McMenamin 2005, 2006, 2007 -* -* Requires firmware (BSD licenced) available from: -* http://linuxdc.cvs.sourceforge.net/linuxdc/linux-sh-dc/sound/oss/aica/firmware/ -* or the maintainer -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "aica.h" - -MODULE_AUTHOR("Adrian McMenamin "); -MODULE_DESCRIPTION("Dreamcast AICA sound (pcm) driver"); -MODULE_LICENSE("GPL"); -MODULE_FIRMWARE("aica_firmware.bin"); - -/* module parameters */ -#define CARD_NAME "AICA" -static int index = -1; -static char *id; -static bool enable = 1; -module_param(index, int, 0444); -MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); -module_param(id, charp, 0444); -MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); -module_param(enable, bool, 0644); -MODULE_PARM_DESC(enable, "Enable " CARD_NAME " soundcard."); - -/* Simple platform device */ -static struct platform_device *pd; -static struct resource aica_memory_space[2] = { - { - .name = "AICA ARM CONTROL", - .start = ARM_RESET_REGISTER, - .flags = IORESOURCE_MEM, - .end = ARM_RESET_REGISTER + 3, - }, - { - .name = "AICA Sound RAM", - .start = SPU_MEMORY_BASE, - .flags = IORESOURCE_MEM, - .end = SPU_MEMORY_BASE + 0x200000 - 1, - }, -}; - -/* SPU specific functions */ -/* spu_write_wait - wait for G2-SH FIFO to clear */ -static void spu_write_wait(void) -{ - int time_count; - time_count = 0; - while (1) { - if (!(readl(G2_FIFO) & 0x11)) - break; - /* To ensure hardware failure doesn't wedge kernel */ - time_count++; - if (time_count > 0x10000) { - snd_printk - ("WARNING: G2 FIFO appears to be blocked.\n"); - break; - } - } -} - -/* spu_memset - write to memory in SPU address space */ -static void spu_memset(u32 toi, u32 what, int length) -{ - int i; - unsigned long flags; - if (snd_BUG_ON(length % 4)) - return; - for (i = 0; i < length; i++) { - if (!(i % 8)) - spu_write_wait(); - local_irq_save(flags); - writel(what, toi + SPU_MEMORY_BASE); - local_irq_restore(flags); - toi++; - } -} - -/* spu_memload - write to SPU address space */ -static void spu_memload(u32 toi, const void *from, int length) -{ - unsigned long flags; - const u32 *froml = from; - u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi); - int i; - u32 val; - length = DIV_ROUND_UP(length, 4); - spu_write_wait(); - for (i = 0; i < length; i++) { - if (!(i % 8)) - spu_write_wait(); - val = *froml; - local_irq_save(flags); - writel(val, to); - local_irq_restore(flags); - froml++; - to++; - } -} - -/* spu_disable - set spu registers to stop sound output */ -static void spu_disable(void) -{ - int i; - unsigned long flags; - u32 regval; - spu_write_wait(); - regval = readl(ARM_RESET_REGISTER); - regval |= 1; - spu_write_wait(); - local_irq_save(flags); - writel(regval, ARM_RESET_REGISTER); - local_irq_restore(flags); - for (i = 0; i < 64; i++) { - spu_write_wait(); - regval = readl(SPU_REGISTER_BASE + (i * 0x80)); - regval = (regval & ~0x4000) | 0x8000; - spu_write_wait(); - local_irq_save(flags); - writel(regval, SPU_REGISTER_BASE + (i * 0x80)); - local_irq_restore(flags); - } -} - -/* spu_enable - set spu registers to enable sound output */ -static void spu_enable(void) -{ - unsigned long flags; - u32 regval = readl(ARM_RESET_REGISTER); - regval &= ~1; - spu_write_wait(); - local_irq_save(flags); - writel(regval, ARM_RESET_REGISTER); - local_irq_restore(flags); -} - -/* - * Halt the sound processor, clear the memory, - * load some default ARM7 code, and then restart ARM7 -*/ -static void spu_reset(void) -{ - unsigned long flags; - spu_disable(); - spu_memset(0, 0, 0x200000 / 4); - /* Put ARM7 in endless loop */ - local_irq_save(flags); - __raw_writel(0xea000002, SPU_MEMORY_BASE); - local_irq_restore(flags); - spu_enable(); -} - -/* aica_chn_start - write to spu to start playback */ -static void aica_chn_start(void) -{ - unsigned long flags; - spu_write_wait(); - local_irq_save(flags); - writel(AICA_CMD_KICK | AICA_CMD_START, (u32 *) AICA_CONTROL_POINT); - local_irq_restore(flags); -} - -/* aica_chn_halt - write to spu to halt playback */ -static void aica_chn_halt(void) -{ - unsigned long flags; - spu_write_wait(); - local_irq_save(flags); - writel(AICA_CMD_KICK | AICA_CMD_STOP, (u32 *) AICA_CONTROL_POINT); - local_irq_restore(flags); -} - -/* ALSA code below */ -static const struct snd_pcm_hardware snd_pcm_aica_playback_hw = { - .info = (SNDRV_PCM_INFO_NONINTERLEAVED), - .formats = - (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_IMA_ADPCM), - .rates = SNDRV_PCM_RATE_8000_48000, - .rate_min = 8000, - .rate_max = 48000, - .channels_min = 1, - .channels_max = 2, - .buffer_bytes_max = AICA_BUFFER_SIZE, - .period_bytes_min = AICA_PERIOD_SIZE, - .period_bytes_max = AICA_PERIOD_SIZE, - .periods_min = AICA_PERIOD_NUMBER, - .periods_max = AICA_PERIOD_NUMBER, -}; - -static int aica_dma_transfer(int channels, int buffer_size, - struct snd_pcm_substream *substream) -{ - int q, err, period_offset; - struct snd_card_aica *dreamcastcard; - struct snd_pcm_runtime *runtime; - unsigned long flags; - err = 0; - dreamcastcard = substream->pcm->private_data; - period_offset = dreamcastcard->clicks; - period_offset %= (AICA_PERIOD_NUMBER / channels); - runtime = substream->runtime; - for (q = 0; q < channels; q++) { - local_irq_save(flags); - err = dma_xfer(AICA_DMA_CHANNEL, - (unsigned long) (runtime->dma_area + - (AICA_BUFFER_SIZE * q) / - channels + - AICA_PERIOD_SIZE * - period_offset), - AICA_CHANNEL0_OFFSET + q * CHANNEL_OFFSET + - AICA_PERIOD_SIZE * period_offset, - buffer_size / channels, AICA_DMA_MODE); - if (unlikely(err < 0)) { - local_irq_restore(flags); - break; - } - dma_wait_for_completion(AICA_DMA_CHANNEL); - local_irq_restore(flags); - } - return err; -} - -static void startup_aica(struct snd_card_aica *dreamcastcard) -{ - spu_memload(AICA_CHANNEL0_CONTROL_OFFSET, - dreamcastcard->channel, sizeof(struct aica_channel)); - aica_chn_start(); -} - -static void run_spu_dma(struct work_struct *work) -{ - int buffer_size; - struct snd_pcm_runtime *runtime; - struct snd_card_aica *dreamcastcard; - dreamcastcard = - container_of(work, struct snd_card_aica, spu_dma_work); - runtime = dreamcastcard->substream->runtime; - if (unlikely(dreamcastcard->dma_check == 0)) { - buffer_size = - frames_to_bytes(runtime, runtime->buffer_size); - if (runtime->channels > 1) - dreamcastcard->channel->flags |= 0x01; - aica_dma_transfer(runtime->channels, buffer_size, - dreamcastcard->substream); - startup_aica(dreamcastcard); - dreamcastcard->clicks = - buffer_size / (AICA_PERIOD_SIZE * runtime->channels); - return; - } else { - aica_dma_transfer(runtime->channels, - AICA_PERIOD_SIZE * runtime->channels, - dreamcastcard->substream); - snd_pcm_period_elapsed(dreamcastcard->substream); - dreamcastcard->clicks++; - if (unlikely(dreamcastcard->clicks >= AICA_PERIOD_NUMBER)) - dreamcastcard->clicks %= AICA_PERIOD_NUMBER; - mod_timer(&dreamcastcard->timer, jiffies + 1); - } -} - -static void aica_period_elapsed(struct timer_list *t) -{ - struct snd_card_aica *dreamcastcard = from_timer(dreamcastcard, - t, timer); - struct snd_pcm_substream *substream = dreamcastcard->substream; - /*timer function - so cannot sleep */ - int play_period; - struct snd_pcm_runtime *runtime; - runtime = substream->runtime; - dreamcastcard = substream->pcm->private_data; - /* Have we played out an additional period? */ - play_period = - frames_to_bytes(runtime, - readl - (AICA_CONTROL_CHANNEL_SAMPLE_NUMBER)) / - AICA_PERIOD_SIZE; - if (play_period == dreamcastcard->current_period) { - /* reschedule the timer */ - mod_timer(&(dreamcastcard->timer), jiffies + 1); - return; - } - if (runtime->channels > 1) - dreamcastcard->current_period = play_period; - if (unlikely(dreamcastcard->dma_check == 0)) - dreamcastcard->dma_check = 1; - schedule_work(&(dreamcastcard->spu_dma_work)); -} - -static void spu_begin_dma(struct snd_pcm_substream *substream) -{ - struct snd_card_aica *dreamcastcard; - struct snd_pcm_runtime *runtime; - runtime = substream->runtime; - dreamcastcard = substream->pcm->private_data; - /*get the queue to do the work */ - schedule_work(&(dreamcastcard->spu_dma_work)); - mod_timer(&dreamcastcard->timer, jiffies + 4); -} - -static int snd_aicapcm_pcm_open(struct snd_pcm_substream - *substream) -{ - struct snd_pcm_runtime *runtime; - struct aica_channel *channel; - struct snd_card_aica *dreamcastcard; - if (!enable) - return -ENOENT; - dreamcastcard = substream->pcm->private_data; - channel = kmalloc(sizeof(struct aica_channel), GFP_KERNEL); - if (!channel) - return -ENOMEM; - /* set defaults for channel */ - channel->sfmt = SM_8BIT; - channel->cmd = AICA_CMD_START; - channel->vol = dreamcastcard->master_volume; - channel->pan = 0x80; - channel->pos = 0; - channel->flags = 0; /* default to mono */ - dreamcastcard->channel = channel; - runtime = substream->runtime; - runtime->hw = snd_pcm_aica_playback_hw; - spu_enable(); - dreamcastcard->clicks = 0; - dreamcastcard->current_period = 0; - dreamcastcard->dma_check = 0; - return 0; -} - -static int snd_aicapcm_pcm_close(struct snd_pcm_substream - *substream) -{ - struct snd_card_aica *dreamcastcard = substream->pcm->private_data; - flush_work(&(dreamcastcard->spu_dma_work)); - del_timer(&dreamcastcard->timer); - dreamcastcard->substream = NULL; - kfree(dreamcastcard->channel); - spu_disable(); - return 0; -} - -static int snd_aicapcm_pcm_prepare(struct snd_pcm_substream - *substream) -{ - struct snd_card_aica *dreamcastcard = substream->pcm->private_data; - if ((substream->runtime)->format == SNDRV_PCM_FORMAT_S16_LE) - dreamcastcard->channel->sfmt = SM_16BIT; - dreamcastcard->channel->freq = substream->runtime->rate; - dreamcastcard->substream = substream; - return 0; -} - -static int snd_aicapcm_pcm_trigger(struct snd_pcm_substream - *substream, int cmd) -{ - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - spu_begin_dma(substream); - break; - case SNDRV_PCM_TRIGGER_STOP: - aica_chn_halt(); - break; - default: - return -EINVAL; - } - return 0; -} - -static unsigned long snd_aicapcm_pcm_pointer(struct snd_pcm_substream - *substream) -{ - return readl(AICA_CONTROL_CHANNEL_SAMPLE_NUMBER); -} - -static const struct snd_pcm_ops snd_aicapcm_playback_ops = { - .open = snd_aicapcm_pcm_open, - .close = snd_aicapcm_pcm_close, - .prepare = snd_aicapcm_pcm_prepare, - .trigger = snd_aicapcm_pcm_trigger, - .pointer = snd_aicapcm_pcm_pointer, -}; - -/* TO DO: set up to handle more than one pcm instance */ -static int __init snd_aicapcmchip(struct snd_card_aica - *dreamcastcard, int pcm_index) -{ - struct snd_pcm *pcm; - int err; - /* AICA has no capture ability */ - err = - snd_pcm_new(dreamcastcard->card, "AICA PCM", pcm_index, 1, 0, - &pcm); - if (unlikely(err < 0)) - return err; - pcm->private_data = dreamcastcard; - strcpy(pcm->name, "AICA PCM"); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, - &snd_aicapcm_playback_ops); - /* Allocate the DMA buffers */ - snd_pcm_set_managed_buffer_all(pcm, - SNDRV_DMA_TYPE_CONTINUOUS, - NULL, - AICA_BUFFER_SIZE, - AICA_BUFFER_SIZE); - return 0; -} - -/* Mixer controls */ -#define aica_pcmswitch_info snd_ctl_boolean_mono_info - -static int aica_pcmswitch_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - ucontrol->value.integer.value[0] = 1; /* TO DO: Fix me */ - return 0; -} - -static int aica_pcmswitch_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - if (ucontrol->value.integer.value[0] == 1) - return 0; /* TO DO: Fix me */ - else - aica_chn_halt(); - return 0; -} - -static int aica_pcmvolume_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 0xFF; - return 0; -} - -static int aica_pcmvolume_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_card_aica *dreamcastcard; - dreamcastcard = kcontrol->private_data; - if (unlikely(!dreamcastcard->channel)) - return -ETXTBSY; /* we've not yet been set up */ - ucontrol->value.integer.value[0] = dreamcastcard->channel->vol; - return 0; -} - -static int aica_pcmvolume_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) -{ - struct snd_card_aica *dreamcastcard; - unsigned int vol; - dreamcastcard = kcontrol->private_data; - if (unlikely(!dreamcastcard->channel)) - return -ETXTBSY; - vol = ucontrol->value.integer.value[0]; - if (vol > 0xff) - return -EINVAL; - if (unlikely(dreamcastcard->channel->vol == vol)) - return 0; - dreamcastcard->channel->vol = ucontrol->value.integer.value[0]; - dreamcastcard->master_volume = ucontrol->value.integer.value[0]; - spu_memload(AICA_CHANNEL0_CONTROL_OFFSET, - dreamcastcard->channel, sizeof(struct aica_channel)); - return 1; -} - -static const struct snd_kcontrol_new snd_aica_pcmswitch_control = { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "PCM Playback Switch", - .index = 0, - .info = aica_pcmswitch_info, - .get = aica_pcmswitch_get, - .put = aica_pcmswitch_put -}; - -static const struct snd_kcontrol_new snd_aica_pcmvolume_control = { - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "PCM Playback Volume", - .index = 0, - .info = aica_pcmvolume_info, - .get = aica_pcmvolume_get, - .put = aica_pcmvolume_put -}; - -static int load_aica_firmware(void) -{ - int err; - const struct firmware *fw_entry; - spu_reset(); - err = request_firmware(&fw_entry, "aica_firmware.bin", &pd->dev); - if (unlikely(err)) - return err; - /* write firmware into memory */ - spu_disable(); - spu_memload(0, fw_entry->data, fw_entry->size); - spu_enable(); - release_firmware(fw_entry); - return err; -} - -static int add_aicamixer_controls(struct snd_card_aica *dreamcastcard) -{ - int err; - err = snd_ctl_add - (dreamcastcard->card, - snd_ctl_new1(&snd_aica_pcmvolume_control, dreamcastcard)); - if (unlikely(err < 0)) - return err; - err = snd_ctl_add - (dreamcastcard->card, - snd_ctl_new1(&snd_aica_pcmswitch_control, dreamcastcard)); - if (unlikely(err < 0)) - return err; - return 0; -} - -static int snd_aica_remove(struct platform_device *devptr) -{ - struct snd_card_aica *dreamcastcard; - dreamcastcard = platform_get_drvdata(devptr); - if (unlikely(!dreamcastcard)) - return -ENODEV; - snd_card_free(dreamcastcard->card); - kfree(dreamcastcard); - return 0; -} - -static int snd_aica_probe(struct platform_device *devptr) -{ - int err; - struct snd_card_aica *dreamcastcard; - dreamcastcard = kzalloc(sizeof(struct snd_card_aica), GFP_KERNEL); - if (unlikely(!dreamcastcard)) - return -ENOMEM; - err = snd_card_new(&devptr->dev, index, SND_AICA_DRIVER, - THIS_MODULE, 0, &dreamcastcard->card); - if (unlikely(err < 0)) { - kfree(dreamcastcard); - return err; - } - strcpy(dreamcastcard->card->driver, "snd_aica"); - strcpy(dreamcastcard->card->shortname, SND_AICA_DRIVER); - strcpy(dreamcastcard->card->longname, - "Yamaha AICA Super Intelligent Sound Processor for SEGA Dreamcast"); - /* Prepare to use the queue */ - INIT_WORK(&(dreamcastcard->spu_dma_work), run_spu_dma); - timer_setup(&dreamcastcard->timer, aica_period_elapsed, 0); - /* Load the PCM 'chip' */ - err = snd_aicapcmchip(dreamcastcard, 0); - if (unlikely(err < 0)) - goto freedreamcast; - /* Add basic controls */ - err = add_aicamixer_controls(dreamcastcard); - if (unlikely(err < 0)) - goto freedreamcast; - /* Register the card with ALSA subsystem */ - err = snd_card_register(dreamcastcard->card); - if (unlikely(err < 0)) - goto freedreamcast; - platform_set_drvdata(devptr, dreamcastcard); - snd_printk - ("ALSA Driver for Yamaha AICA Super Intelligent Sound Processor\n"); - return 0; - freedreamcast: - snd_card_free(dreamcastcard->card); - kfree(dreamcastcard); - return err; -} - -static struct platform_driver snd_aica_driver = { - .probe = snd_aica_probe, - .remove = snd_aica_remove, - .driver = { - .name = SND_AICA_DRIVER, - }, -}; - -static int __init aica_init(void) -{ - int err; - err = platform_driver_register(&snd_aica_driver); - if (unlikely(err < 0)) - return err; - pd = platform_device_register_simple(SND_AICA_DRIVER, -1, - aica_memory_space, 2); - if (IS_ERR(pd)) { - platform_driver_unregister(&snd_aica_driver); - return PTR_ERR(pd); - } - /* Load the firmware */ - return load_aica_firmware(); -} - -static void __exit aica_exit(void) -{ - platform_device_unregister(pd); - platform_driver_unregister(&snd_aica_driver); - /* Kill any sound still playing and reset ARM7 to safe state */ - spu_reset(); -} - -module_init(aica_init); -module_exit(aica_exit); diff --git a/sound/sh/aica.h b/sound/sh/aica.h deleted file mode 100644 index 021b132e088e82..00000000000000 --- a/sound/sh/aica.h +++ /dev/null @@ -1,68 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* aica.h - * Header file for ALSA driver for - * Sega Dreamcast Yamaha AICA sound - * Copyright Adrian McMenamin - * - * 2006 - */ - -/* SPU memory and register constants etc */ -#define G2_FIFO 0xa05f688c -#define SPU_MEMORY_BASE 0xA0800000 -#define ARM_RESET_REGISTER 0xA0702C00 -#define SPU_REGISTER_BASE 0xA0700000 - -/* AICA channels stuff */ -#define AICA_CONTROL_POINT 0xA0810000 -#define AICA_CONTROL_CHANNEL_SAMPLE_NUMBER 0xA0810008 -#define AICA_CHANNEL0_CONTROL_OFFSET 0x10004 - -/* Command values */ -#define AICA_CMD_KICK 0x80000000 -#define AICA_CMD_NONE 0 -#define AICA_CMD_START 1 -#define AICA_CMD_STOP 2 -#define AICA_CMD_VOL 3 - -/* Sound modes */ -#define SM_8BIT 1 -#define SM_16BIT 0 -#define SM_ADPCM 2 - -/* Buffer and period size */ -#define AICA_BUFFER_SIZE 0x8000 -#define AICA_PERIOD_SIZE 0x800 -#define AICA_PERIOD_NUMBER 16 - -#define AICA_CHANNEL0_OFFSET 0x11000 -#define AICA_CHANNEL1_OFFSET 0x21000 -#define CHANNEL_OFFSET 0x10000 - -#define AICA_DMA_CHANNEL 5 -#define AICA_DMA_MODE 5 - -#define SND_AICA_DRIVER "AICA" - -struct aica_channel { - uint32_t cmd; /* Command ID */ - uint32_t pos; /* Sample position */ - uint32_t length; /* Sample length */ - uint32_t freq; /* Frequency */ - uint32_t vol; /* Volume 0-255 */ - uint32_t pan; /* Pan 0-255 */ - uint32_t sfmt; /* Sound format */ - uint32_t flags; /* Bit flags */ -}; - -struct snd_card_aica { - struct work_struct spu_dma_work; - struct snd_card *card; - struct aica_channel *channel; - struct snd_pcm_substream *substream; - int clicks; - int current_period; - struct timer_list timer; - int master_volume; - int dma_check; -}; diff --git a/sound/sh/sh_dac_audio.c b/sound/sh/sh_dac_audio.c deleted file mode 100644 index 8ebd972846acb5..00000000000000 --- a/sound/sh/sh_dac_audio.c +++ /dev/null @@ -1,412 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * sh_dac_audio.c - SuperH DAC audio driver for ALSA - * - * Copyright (c) 2009 by Rafael Ignacio Zurita - * - * Based on sh_dac_audio.c (Copyright (C) 2004, 2005 by Andriy Skulysh) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -MODULE_AUTHOR("Rafael Ignacio Zurita "); -MODULE_DESCRIPTION("SuperH DAC audio driver"); -MODULE_LICENSE("GPL"); - -/* Module Parameters */ -static int index = SNDRV_DEFAULT_IDX1; -static char *id = SNDRV_DEFAULT_STR1; -module_param(index, int, 0444); -MODULE_PARM_DESC(index, "Index value for SuperH DAC audio."); -module_param(id, charp, 0444); -MODULE_PARM_DESC(id, "ID string for SuperH DAC audio."); - -/* main struct */ -struct snd_sh_dac { - struct snd_card *card; - struct snd_pcm_substream *substream; - struct hrtimer hrtimer; - ktime_t wakeups_per_second; - - int rate; - int empty; - char *data_buffer, *buffer_begin, *buffer_end; - int processed; /* bytes proccesed, to compare with period_size */ - int buffer_size; - struct dac_audio_pdata *pdata; -}; - - -static void dac_audio_start_timer(struct snd_sh_dac *chip) -{ - hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, - HRTIMER_MODE_REL); -} - -static void dac_audio_stop_timer(struct snd_sh_dac *chip) -{ - hrtimer_cancel(&chip->hrtimer); -} - -static void dac_audio_reset(struct snd_sh_dac *chip) -{ - dac_audio_stop_timer(chip); - chip->buffer_begin = chip->buffer_end = chip->data_buffer; - chip->processed = 0; - chip->empty = 1; -} - -static void dac_audio_set_rate(struct snd_sh_dac *chip) -{ - chip->wakeups_per_second = 1000000000 / chip->rate; -} - - -/* PCM INTERFACE */ - -static const struct snd_pcm_hardware snd_sh_dac_pcm_hw = { - .info = (SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_HALF_DUPLEX), - .formats = SNDRV_PCM_FMTBIT_U8, - .rates = SNDRV_PCM_RATE_8000, - .rate_min = 8000, - .rate_max = 8000, - .channels_min = 1, - .channels_max = 1, - .buffer_bytes_max = (48*1024), - .period_bytes_min = 1, - .period_bytes_max = (48*1024), - .periods_min = 1, - .periods_max = 1024, -}; - -static int snd_sh_dac_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - struct snd_pcm_runtime *runtime = substream->runtime; - - runtime->hw = snd_sh_dac_pcm_hw; - - chip->substream = substream; - chip->buffer_begin = chip->buffer_end = chip->data_buffer; - chip->processed = 0; - chip->empty = 1; - - chip->pdata->start(chip->pdata); - - return 0; -} - -static int snd_sh_dac_pcm_close(struct snd_pcm_substream *substream) -{ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - - chip->substream = NULL; - - dac_audio_stop_timer(chip); - chip->pdata->stop(chip->pdata); - - return 0; -} - -static int snd_sh_dac_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - struct snd_pcm_runtime *runtime = chip->substream->runtime; - - chip->buffer_size = runtime->buffer_size; - memset(chip->data_buffer, 0, chip->pdata->buffer_size); - - return 0; -} - -static int snd_sh_dac_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - dac_audio_start_timer(chip); - break; - case SNDRV_PCM_TRIGGER_STOP: - chip->buffer_begin = chip->buffer_end = chip->data_buffer; - chip->processed = 0; - chip->empty = 1; - dac_audio_stop_timer(chip); - break; - default: - return -EINVAL; - } - - return 0; -} - -static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void __user *src, unsigned long count) -{ - /* channel is not used (interleaved data) */ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - - if (copy_from_user_toio(chip->data_buffer + pos, src, count)) - return -EFAULT; - chip->buffer_end = chip->data_buffer + pos + count; - - if (chip->empty) { - chip->empty = 0; - dac_audio_start_timer(chip); - } - - return 0; -} - -static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void *src, unsigned long count) -{ - /* channel is not used (interleaved data) */ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - - memcpy_toio(chip->data_buffer + pos, src, count); - chip->buffer_end = chip->data_buffer + pos + count; - - if (chip->empty) { - chip->empty = 0; - dac_audio_start_timer(chip); - } - - return 0; -} - -static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - unsigned long count) -{ - /* channel is not used (interleaved data) */ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - - memset_io(chip->data_buffer + pos, 0, count); - chip->buffer_end = chip->data_buffer + pos + count; - - if (chip->empty) { - chip->empty = 0; - dac_audio_start_timer(chip); - } - - return 0; -} - -static -snd_pcm_uframes_t snd_sh_dac_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_sh_dac *chip = snd_pcm_substream_chip(substream); - int pointer = chip->buffer_begin - chip->data_buffer; - - return pointer; -} - -/* pcm ops */ -static const struct snd_pcm_ops snd_sh_dac_pcm_ops = { - .open = snd_sh_dac_pcm_open, - .close = snd_sh_dac_pcm_close, - .prepare = snd_sh_dac_pcm_prepare, - .trigger = snd_sh_dac_pcm_trigger, - .pointer = snd_sh_dac_pcm_pointer, - .copy_user = snd_sh_dac_pcm_copy, - .copy_kernel = snd_sh_dac_pcm_copy_kernel, - .fill_silence = snd_sh_dac_pcm_silence, - .mmap = snd_pcm_lib_mmap_iomem, -}; - -static int snd_sh_dac_pcm(struct snd_sh_dac *chip, int device) -{ - int err; - struct snd_pcm *pcm; - - /* device should be always 0 for us */ - err = snd_pcm_new(chip->card, "SH_DAC PCM", device, 1, 0, &pcm); - if (err < 0) - return err; - - pcm->private_data = chip; - strcpy(pcm->name, "SH_DAC PCM"); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sh_dac_pcm_ops); - - /* buffer size=48K */ - snd_pcm_set_managed_buffer_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, - NULL, 48 * 1024, 48 * 1024); - - return 0; -} -/* END OF PCM INTERFACE */ - - -/* driver .remove -- destructor */ -static int snd_sh_dac_remove(struct platform_device *devptr) -{ - snd_card_free(platform_get_drvdata(devptr)); - return 0; -} - -/* free -- it has been defined by create */ -static int snd_sh_dac_free(struct snd_sh_dac *chip) -{ - /* release the data */ - kfree(chip->data_buffer); - kfree(chip); - - return 0; -} - -static int snd_sh_dac_dev_free(struct snd_device *device) -{ - struct snd_sh_dac *chip = device->device_data; - - return snd_sh_dac_free(chip); -} - -static enum hrtimer_restart sh_dac_audio_timer(struct hrtimer *handle) -{ - struct snd_sh_dac *chip = container_of(handle, struct snd_sh_dac, - hrtimer); - struct snd_pcm_runtime *runtime = chip->substream->runtime; - ssize_t b_ps = frames_to_bytes(runtime, runtime->period_size); - - if (!chip->empty) { - sh_dac_output(*chip->buffer_begin, chip->pdata->channel); - chip->buffer_begin++; - - chip->processed++; - if (chip->processed >= b_ps) { - chip->processed -= b_ps; - snd_pcm_period_elapsed(chip->substream); - } - - if (chip->buffer_begin == (chip->data_buffer + - chip->buffer_size - 1)) - chip->buffer_begin = chip->data_buffer; - - if (chip->buffer_begin == chip->buffer_end) - chip->empty = 1; - - } - - if (!chip->empty) - hrtimer_start(&chip->hrtimer, chip->wakeups_per_second, - HRTIMER_MODE_REL); - - return HRTIMER_NORESTART; -} - -/* create -- chip-specific constructor for the cards components */ -static int snd_sh_dac_create(struct snd_card *card, - struct platform_device *devptr, - struct snd_sh_dac **rchip) -{ - struct snd_sh_dac *chip; - int err; - - static const struct snd_device_ops ops = { - .dev_free = snd_sh_dac_dev_free, - }; - - *rchip = NULL; - - chip = kzalloc(sizeof(*chip), GFP_KERNEL); - if (chip == NULL) - return -ENOMEM; - - chip->card = card; - - hrtimer_init(&chip->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - chip->hrtimer.function = sh_dac_audio_timer; - - dac_audio_reset(chip); - chip->rate = 8000; - dac_audio_set_rate(chip); - - chip->pdata = devptr->dev.platform_data; - - chip->data_buffer = kmalloc(chip->pdata->buffer_size, GFP_KERNEL); - if (chip->data_buffer == NULL) { - kfree(chip); - return -ENOMEM; - } - - err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); - if (err < 0) { - snd_sh_dac_free(chip); - return err; - } - - *rchip = chip; - - return 0; -} - -/* driver .probe -- constructor */ -static int snd_sh_dac_probe(struct platform_device *devptr) -{ - struct snd_sh_dac *chip; - struct snd_card *card; - int err; - - err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card); - if (err < 0) { - snd_printk(KERN_ERR "cannot allocate the card\n"); - return err; - } - - err = snd_sh_dac_create(card, devptr, &chip); - if (err < 0) - goto probe_error; - - err = snd_sh_dac_pcm(chip, 0); - if (err < 0) - goto probe_error; - - strcpy(card->driver, "snd_sh_dac"); - strcpy(card->shortname, "SuperH DAC audio driver"); - printk(KERN_INFO "%s %s", card->longname, card->shortname); - - err = snd_card_register(card); - if (err < 0) - goto probe_error; - - snd_printk(KERN_INFO "ALSA driver for SuperH DAC audio"); - - platform_set_drvdata(devptr, card); - return 0; - -probe_error: - snd_card_free(card); - return err; -} - -/* - * "driver" definition - */ -static struct platform_driver sh_dac_driver = { - .probe = snd_sh_dac_probe, - .remove = snd_sh_dac_remove, - .driver = { - .name = "dac_audio", - }, -}; - -module_platform_driver(sh_dac_driver); From patchwork Fri Jan 13 06:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644797 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E57DC678D7 for ; Fri, 13 Jan 2023 06:27:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240876AbjAMG1W (ORCPT ); Fri, 13 Jan 2023 01:27:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236952AbjAMGYr (ORCPT ); Fri, 13 Jan 2023 01:24:47 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B766A0F5; Thu, 12 Jan 2023 22:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mxBIoTcWoM961bskFu4vgLYA4iK6lfkfHo46ovOHhdY=; b=epactF3LWIS1c8xybu121AnX4l mxQDeqmEC9J8cgMc2SIYAO9NzF3h0YlU8xbCTYRLLK24zqc8kEMH0PpbDIl1CALQ06M6j2t+DvW/2 52IjFzvuXiBDn229AAQmQ76IVBLDEALsaXsG/rhqbYhzaI4Hb2k5FYwBW/QtpL+GpgBj1CYNBCjoU Wow0ecEypZirO8g6qBKEcpON8H7jgnTwizxUEhR74JGhqggyXfr0uC5oDRw7YO7Ldj7yKS+YzcUmZ aD+BC5AU+OusXU3+GAHmRsZapXMUIGr4gkeRILIjbZ4eJzhz4I3ZIHuh91N7YMYtmI2wXUBJeRcBz reMo6ZfA==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDTy-000lWK-J8; Fri, 13 Jan 2023 06:24:07 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 06/22] watchdog: remove the shwdt driver Date: Fri, 13 Jan 2023 07:23:23 +0100 Message-Id: <20230113062339.1909087-7-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- .../watchdog/watchdog-parameters.rst | 12 - drivers/watchdog/Kconfig | 20 - drivers/watchdog/Makefile | 3 - drivers/watchdog/shwdt.c | 344 ------------------ 4 files changed, 379 deletions(-) delete mode 100644 drivers/watchdog/shwdt.c diff --git a/Documentation/watchdog/watchdog-parameters.rst b/Documentation/watchdog/watchdog-parameters.rst index 29153eed668900..553ac2f8ae23f7 100644 --- a/Documentation/watchdog/watchdog-parameters.rst +++ b/Documentation/watchdog/watchdog-parameters.rst @@ -579,18 +579,6 @@ scx200_wdt: ------------------------------------------------- -shwdt: - clock_division_ratio: - Clock division ratio. Valid ranges are from 0x5 (1.31ms) - to 0x7 (5.25ms). (default=7) - heartbeat: - Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default=30 - nowayout: - Watchdog cannot be stopped once started - (default=kernel config parameter) - -------------------------------------------------- - smsc37b787_wdt: timeout: range is 1-255 units, default is 60 diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 0bc40b763b0652..7db0a5e636cf65 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -2015,26 +2015,6 @@ config DIAG288_WATCHDOG To compile this driver as a module, choose M here. The module will be called diag288_wdt. -# SUPERH (sh + sh64) Architecture - -config SH_WDT - tristate "SuperH Watchdog" - depends on SUPERH && (CPU_SH3 || CPU_SH4 || COMPILE_TEST) - select WATCHDOG_CORE - help - This driver adds watchdog support for the integrated watchdog in the - SuperH processors. If you have one of these processors and wish - to have watchdog support enabled, say Y, otherwise say N. - - As a side note, saying Y here will automatically boost HZ to 1000 - so that the timer has a chance to clear the overflow counter. On - slower systems (such as the SH-2 and SH-3) this will likely yield - some performance issues. As such, the WDT should be avoided here - unless it is absolutely necessary. - - To compile this driver as a module, choose M here: the - module will be called shwdt. - # SPARC Architecture # SPARC64 Architecture diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 9cbf6580f16c9f..a852ab4d7176ac 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -195,9 +195,6 @@ obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o # S390 Architecture obj-$(CONFIG_DIAG288_WATCHDOG) += diag288_wdt.o -# SUPERH (sh + sh64) Architecture -obj-$(CONFIG_SH_WDT) += shwdt.o - # SPARC Architecture # SPARC64 Architecture diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c deleted file mode 100644 index f55533e0e0454e..00000000000000 --- a/drivers/watchdog/shwdt.c +++ /dev/null @@ -1,344 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* - * drivers/watchdog/shwdt.c - * - * Watchdog driver for integrated watchdog in the SuperH processors. - * - * Copyright (C) 2001 - 2012 Paul Mundt - * - * 14-Dec-2001 Matt Domsch - * Added nowayout module option to override CONFIG_WATCHDOG_NOWAYOUT - * - * 19-Apr-2002 Rob Radez - * Added expect close support, made emulated timeout runtime changeable - * general cleanups, add some ioctls - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRV_NAME "sh-wdt" - -/* - * Default clock division ratio is 5.25 msecs. For an additional table of - * values, consult the asm-sh/watchdog.h. Overload this at module load - * time. - * - * In order for this to work reliably we need to have HZ set to 1000 or - * something quite higher than 100 (or we need a proper high-res timer - * implementation that will deal with this properly), otherwise the 10ms - * resolution of a jiffy is enough to trigger the overflow. For things like - * the SH-4 and SH-5, this isn't necessarily that big of a problem, though - * for the SH-2 and SH-3, this isn't recommended unless the WDT is absolutely - * necssary. - * - * As a result of this timing problem, the only modes that are particularly - * feasible are the 4096 and the 2048 divisors, which yield 5.25 and 2.62ms - * overflow periods respectively. - * - * Also, since we can't really expect userspace to be responsive enough - * before the overflow happens, we maintain two separate timers .. One in - * the kernel for clearing out WOVF every 2ms or so (again, this depends on - * HZ == 1000), and another for monitoring userspace writes to the WDT device. - * - * As such, we currently use a configurable heartbeat interval which defaults - * to 30s. In this case, the userspace daemon is only responsible for periodic - * writes to the device before the next heartbeat is scheduled. If the daemon - * misses its deadline, the kernel timer will allow the WDT to overflow. - */ -static int clock_division_ratio = WTCSR_CKS_4096; -#define next_ping_period(cks) (jiffies + msecs_to_jiffies(cks - 4)) - -#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ -static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ -static bool nowayout = WATCHDOG_NOWAYOUT; -static unsigned long next_heartbeat; - -struct sh_wdt { - void __iomem *base; - struct device *dev; - struct clk *clk; - spinlock_t lock; - - struct timer_list timer; -}; - -static int sh_wdt_start(struct watchdog_device *wdt_dev) -{ - struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); - unsigned long flags; - u8 csr; - - pm_runtime_get_sync(wdt->dev); - clk_enable(wdt->clk); - - spin_lock_irqsave(&wdt->lock, flags); - - next_heartbeat = jiffies + (heartbeat * HZ); - mod_timer(&wdt->timer, next_ping_period(clock_division_ratio)); - - csr = sh_wdt_read_csr(); - csr |= WTCSR_WT | clock_division_ratio; - sh_wdt_write_csr(csr); - - sh_wdt_write_cnt(0); - - /* - * These processors have a bit of an inconsistent initialization - * process.. starting with SH-3, RSTS was moved to WTCSR, and the - * RSTCSR register was removed. - * - * On the SH-2 however, in addition with bits being in different - * locations, we must deal with RSTCSR outright.. - */ - csr = sh_wdt_read_csr(); - csr |= WTCSR_TME; - csr &= ~WTCSR_RSTS; - sh_wdt_write_csr(csr); - -#ifdef CONFIG_CPU_SH2 - csr = sh_wdt_read_rstcsr(); - csr &= ~RSTCSR_RSTS; - sh_wdt_write_rstcsr(csr); -#endif - spin_unlock_irqrestore(&wdt->lock, flags); - - return 0; -} - -static int sh_wdt_stop(struct watchdog_device *wdt_dev) -{ - struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); - unsigned long flags; - u8 csr; - - spin_lock_irqsave(&wdt->lock, flags); - - del_timer(&wdt->timer); - - csr = sh_wdt_read_csr(); - csr &= ~WTCSR_TME; - sh_wdt_write_csr(csr); - - spin_unlock_irqrestore(&wdt->lock, flags); - - clk_disable(wdt->clk); - pm_runtime_put_sync(wdt->dev); - - return 0; -} - -static int sh_wdt_keepalive(struct watchdog_device *wdt_dev) -{ - struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); - unsigned long flags; - - spin_lock_irqsave(&wdt->lock, flags); - next_heartbeat = jiffies + (heartbeat * HZ); - spin_unlock_irqrestore(&wdt->lock, flags); - - return 0; -} - -static int sh_wdt_set_heartbeat(struct watchdog_device *wdt_dev, unsigned t) -{ - struct sh_wdt *wdt = watchdog_get_drvdata(wdt_dev); - unsigned long flags; - - if (unlikely(t < 1 || t > 3600)) /* arbitrary upper limit */ - return -EINVAL; - - spin_lock_irqsave(&wdt->lock, flags); - heartbeat = t; - wdt_dev->timeout = t; - spin_unlock_irqrestore(&wdt->lock, flags); - - return 0; -} - -static void sh_wdt_ping(struct timer_list *t) -{ - struct sh_wdt *wdt = from_timer(wdt, t, timer); - unsigned long flags; - - spin_lock_irqsave(&wdt->lock, flags); - if (time_before(jiffies, next_heartbeat)) { - u8 csr; - - csr = sh_wdt_read_csr(); - csr &= ~WTCSR_IOVF; - sh_wdt_write_csr(csr); - - sh_wdt_write_cnt(0); - - mod_timer(&wdt->timer, next_ping_period(clock_division_ratio)); - } else - dev_warn(wdt->dev, "Heartbeat lost! Will not ping " - "the watchdog\n"); - spin_unlock_irqrestore(&wdt->lock, flags); -} - -static const struct watchdog_info sh_wdt_info = { - .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | - WDIOF_MAGICCLOSE, - .firmware_version = 1, - .identity = "SH WDT", -}; - -static const struct watchdog_ops sh_wdt_ops = { - .owner = THIS_MODULE, - .start = sh_wdt_start, - .stop = sh_wdt_stop, - .ping = sh_wdt_keepalive, - .set_timeout = sh_wdt_set_heartbeat, -}; - -static struct watchdog_device sh_wdt_dev = { - .info = &sh_wdt_info, - .ops = &sh_wdt_ops, -}; - -static int sh_wdt_probe(struct platform_device *pdev) -{ - struct sh_wdt *wdt; - int rc; - - /* - * As this driver only covers the global watchdog case, reject - * any attempts to register per-CPU watchdogs. - */ - if (pdev->id != -1) - return -EINVAL; - - wdt = devm_kzalloc(&pdev->dev, sizeof(struct sh_wdt), GFP_KERNEL); - if (unlikely(!wdt)) - return -ENOMEM; - - wdt->dev = &pdev->dev; - - wdt->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(wdt->clk)) { - /* - * Clock framework support is optional, continue on - * anyways if we don't find a matching clock. - */ - wdt->clk = NULL; - } - - wdt->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(wdt->base)) - return PTR_ERR(wdt->base); - - watchdog_set_nowayout(&sh_wdt_dev, nowayout); - watchdog_set_drvdata(&sh_wdt_dev, wdt); - sh_wdt_dev.parent = &pdev->dev; - - spin_lock_init(&wdt->lock); - - rc = sh_wdt_set_heartbeat(&sh_wdt_dev, heartbeat); - if (unlikely(rc)) { - /* Default timeout if invalid */ - sh_wdt_set_heartbeat(&sh_wdt_dev, WATCHDOG_HEARTBEAT); - - dev_warn(&pdev->dev, - "heartbeat value must be 1<=x<=3600, using %d\n", - sh_wdt_dev.timeout); - } - - dev_info(&pdev->dev, "configured with heartbeat=%d sec (nowayout=%d)\n", - sh_wdt_dev.timeout, nowayout); - - rc = watchdog_register_device(&sh_wdt_dev); - if (unlikely(rc)) { - dev_err(&pdev->dev, "Can't register watchdog (err=%d)\n", rc); - return rc; - } - - timer_setup(&wdt->timer, sh_wdt_ping, 0); - wdt->timer.expires = next_ping_period(clock_division_ratio); - - dev_info(&pdev->dev, "initialized.\n"); - - pm_runtime_enable(&pdev->dev); - - return 0; -} - -static int sh_wdt_remove(struct platform_device *pdev) -{ - watchdog_unregister_device(&sh_wdt_dev); - - pm_runtime_disable(&pdev->dev); - - return 0; -} - -static void sh_wdt_shutdown(struct platform_device *pdev) -{ - sh_wdt_stop(&sh_wdt_dev); -} - -static struct platform_driver sh_wdt_driver = { - .driver = { - .name = DRV_NAME, - }, - - .probe = sh_wdt_probe, - .remove = sh_wdt_remove, - .shutdown = sh_wdt_shutdown, -}; - -static int __init sh_wdt_init(void) -{ - if (unlikely(clock_division_ratio < 0x5 || - clock_division_ratio > 0x7)) { - clock_division_ratio = WTCSR_CKS_4096; - - pr_info("divisor must be 0x5<=x<=0x7, using %d\n", - clock_division_ratio); - } - - return platform_driver_register(&sh_wdt_driver); -} - -static void __exit sh_wdt_exit(void) -{ - platform_driver_unregister(&sh_wdt_driver); -} -module_init(sh_wdt_init); -module_exit(sh_wdt_exit); - -MODULE_AUTHOR("Paul Mundt "); -MODULE_DESCRIPTION("SuperH watchdog driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:" DRV_NAME); - -module_param(clock_division_ratio, int, 0); -MODULE_PARM_DESC(clock_division_ratio, - "Clock division ratio. Valid ranges are from 0x5 (1.31ms) " - "to 0x7 (5.25ms). (default=" __MODULE_STRING(WTCSR_CKS_4096) ")"); - -module_param(heartbeat, int, 0); -MODULE_PARM_DESC(heartbeat, - "Watchdog heartbeat in seconds. (1 <= heartbeat <= 3600, default=" - __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); - -module_param(nowayout, bool, 0); -MODULE_PARM_DESC(nowayout, - "Watchdog cannot be stopped once started (default=" - __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); From patchwork Fri Jan 13 06:23:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644795 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9469C54EBE for ; Fri, 13 Jan 2023 06:27:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240190AbjAMG1g (ORCPT ); Fri, 13 Jan 2023 01:27:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239960AbjAMGZF (ORCPT ); Fri, 13 Jan 2023 01:25:05 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A72D5F; Thu, 12 Jan 2023 22:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=2hPC7zlGA9AoDVV3UDFLI3T20RnHyuVZW1qr++X92oI=; b=U0IxPDIbDusxYyls7GAP+XZ9hs WK31Rw57DTsJeVGBg+mDkhc5spH2HTT6S2bZUnUWnMFMzjuRTQxHiqWupbwLk1M9gy0H80/2TyLAr 4yZAcNURNOrPm5QlFyeBEx9lyjEDdoNyEPtXoGtYw9kpeDRvlQIm1jqEylL4Lcd6JGXKqeXaBK+NJ +uk9CHMdgG+2G6uVa800FbCPfygKQQtSqfcvxslcKVFQl/oOPnfpUDUTut6HA5FBLlzfI2NTovRY8 7+tTh7eQy6PkL+5LvQ1o6k2FC089tht54mg8KW+qjbhQzzqpgcZGx2HuDPkTk929Z5PbzaycfkZ5t Zk42lm1g==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDU8-000lc0-50; Fri, 13 Jan 2023 06:24:16 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 09/22] i2c: remove i2c-sh7760 Date: Fri, 13 Jan 2023 07:23:26 +0100 Message-Id: <20230113062339.1909087-10-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- drivers/i2c/busses/Kconfig | 9 - drivers/i2c/busses/Makefile | 1 - drivers/i2c/busses/i2c-sh7760.c | 565 -------------------------------- 3 files changed, 575 deletions(-) delete mode 100644 drivers/i2c/busses/i2c-sh7760.c diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 22602c512a6e50..44267a023fd19a 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -1016,15 +1016,6 @@ config I2C_S3C2410 Say Y here to include support for I2C controller in the Samsung SoCs (S3C, S5Pv210, Exynos). -config I2C_SH7760 - tristate "Renesas SH7760 I2C Controller" - depends on CPU_SUBTYPE_SH7760 - help - This driver supports the 2 I2C interfaces on the Renesas SH7760. - - This driver can also be built as a module. If so, the module - will be called i2c-sh7760. - config I2C_SH_MOBILE tristate "SuperH Mobile I2C Controller" depends on ARCH_RENESAS || COMPILE_TEST diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index e73cdb1d2b5a85..6be213e5e4dd16 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -104,7 +104,6 @@ obj-$(CONFIG_I2C_RIIC) += i2c-riic.o obj-$(CONFIG_I2C_RK3X) += i2c-rk3x.o obj-$(CONFIG_I2C_RZV2M) += i2c-rzv2m.o obj-$(CONFIG_I2C_S3C2410) += i2c-s3c2410.o -obj-$(CONFIG_I2C_SH7760) += i2c-sh7760.o obj-$(CONFIG_I2C_SH_MOBILE) += i2c-sh_mobile.o obj-$(CONFIG_I2C_SIMTEC) += i2c-simtec.o obj-$(CONFIG_I2C_SPRD) += i2c-sprd.o diff --git a/drivers/i2c/busses/i2c-sh7760.c b/drivers/i2c/busses/i2c-sh7760.c deleted file mode 100644 index 319d1fa617c883..00000000000000 --- a/drivers/i2c/busses/i2c-sh7760.c +++ /dev/null @@ -1,565 +0,0 @@ -/* - * I2C bus driver for the SH7760 I2C Interfaces. - * - * (c) 2005-2008 MSC Vertriebsges.m.b.H, Manuel Lauss - * - * licensed under the terms outlined in the file COPYING. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* register offsets */ -#define I2CSCR 0x0 /* slave ctrl */ -#define I2CMCR 0x4 /* master ctrl */ -#define I2CSSR 0x8 /* slave status */ -#define I2CMSR 0xC /* master status */ -#define I2CSIER 0x10 /* slave irq enable */ -#define I2CMIER 0x14 /* master irq enable */ -#define I2CCCR 0x18 /* clock dividers */ -#define I2CSAR 0x1c /* slave address */ -#define I2CMAR 0x20 /* master address */ -#define I2CRXTX 0x24 /* data port */ -#define I2CFCR 0x28 /* fifo control */ -#define I2CFSR 0x2C /* fifo status */ -#define I2CFIER 0x30 /* fifo irq enable */ -#define I2CRFDR 0x34 /* rx fifo count */ -#define I2CTFDR 0x38 /* tx fifo count */ - -#define REGSIZE 0x3C - -#define MCR_MDBS 0x80 /* non-fifo mode switch */ -#define MCR_FSCL 0x40 /* override SCL pin */ -#define MCR_FSDA 0x20 /* override SDA pin */ -#define MCR_OBPC 0x10 /* override pins */ -#define MCR_MIE 0x08 /* master if enable */ -#define MCR_TSBE 0x04 -#define MCR_FSB 0x02 /* force stop bit */ -#define MCR_ESG 0x01 /* en startbit gen. */ - -#define MSR_MNR 0x40 /* nack received */ -#define MSR_MAL 0x20 /* arbitration lost */ -#define MSR_MST 0x10 /* sent a stop */ -#define MSR_MDE 0x08 -#define MSR_MDT 0x04 -#define MSR_MDR 0x02 -#define MSR_MAT 0x01 /* slave addr xfer done */ - -#define MIE_MNRE 0x40 /* nack irq en */ -#define MIE_MALE 0x20 /* arblos irq en */ -#define MIE_MSTE 0x10 /* stop irq en */ -#define MIE_MDEE 0x08 -#define MIE_MDTE 0x04 -#define MIE_MDRE 0x02 -#define MIE_MATE 0x01 /* address sent irq en */ - -#define FCR_RFRST 0x02 /* reset rx fifo */ -#define FCR_TFRST 0x01 /* reset tx fifo */ - -#define FSR_TEND 0x04 /* last byte sent */ -#define FSR_RDF 0x02 /* rx fifo trigger */ -#define FSR_TDFE 0x01 /* tx fifo empty */ - -#define FIER_TEIE 0x04 /* tx fifo empty irq en */ -#define FIER_RXIE 0x02 /* rx fifo trig irq en */ -#define FIER_TXIE 0x01 /* tx fifo trig irq en */ - -#define FIFO_SIZE 16 - -struct cami2c { - void __iomem *iobase; - struct i2c_adapter adap; - - /* message processing */ - struct i2c_msg *msg; -#define IDF_SEND 1 -#define IDF_RECV 2 -#define IDF_STOP 4 - int flags; - -#define IDS_DONE 1 -#define IDS_ARBLOST 2 -#define IDS_NACK 4 - int status; - struct completion xfer_done; - - int irq; - struct resource *ioarea; -}; - -static inline void OUT32(struct cami2c *cam, int reg, unsigned long val) -{ - __raw_writel(val, (unsigned long)cam->iobase + reg); -} - -static inline unsigned long IN32(struct cami2c *cam, int reg) -{ - return __raw_readl((unsigned long)cam->iobase + reg); -} - -static irqreturn_t sh7760_i2c_irq(int irq, void *ptr) -{ - struct cami2c *id = ptr; - struct i2c_msg *msg = id->msg; - char *data = msg->buf; - unsigned long msr, fsr, fier, len; - - msr = IN32(id, I2CMSR); - fsr = IN32(id, I2CFSR); - - /* arbitration lost */ - if (msr & MSR_MAL) { - OUT32(id, I2CMCR, 0); - OUT32(id, I2CSCR, 0); - OUT32(id, I2CSAR, 0); - id->status |= IDS_DONE | IDS_ARBLOST; - goto out; - } - - if (msr & MSR_MNR) { - /* NACK handling is very screwed up. After receiving a - * NAK IRQ one has to wait a bit before writing to any - * registers, or the ctl will lock up. After that delay - * do a normal i2c stop. Then wait at least 1 ms before - * attempting another transfer or ctl will stop working - */ - udelay(100); /* wait or risk ctl hang */ - OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); - OUT32(id, I2CMCR, MCR_MIE | MCR_FSB); - OUT32(id, I2CFIER, 0); - OUT32(id, I2CMIER, MIE_MSTE); - OUT32(id, I2CSCR, 0); - OUT32(id, I2CSAR, 0); - id->status |= IDS_NACK; - msr &= ~MSR_MAT; - fsr = 0; - /* In some cases the MST bit is also set. */ - } - - /* i2c-stop was sent */ - if (msr & MSR_MST) { - id->status |= IDS_DONE; - goto out; - } - - /* i2c slave addr was sent; set to "normal" operation */ - if (msr & MSR_MAT) - OUT32(id, I2CMCR, MCR_MIE); - - fier = IN32(id, I2CFIER); - - if (fsr & FSR_RDF) { - len = IN32(id, I2CRFDR); - if (msg->len <= len) { - if (id->flags & IDF_STOP) { - OUT32(id, I2CMCR, MCR_MIE | MCR_FSB); - OUT32(id, I2CFIER, 0); - /* manual says: wait >= 0.5 SCL times */ - udelay(5); - /* next int should be MST */ - } else { - id->status |= IDS_DONE; - /* keep the RDF bit: ctrl holds SCL low - * until the setup for the next i2c_msg - * clears this bit. - */ - fsr &= ~FSR_RDF; - } - } - while (msg->len && len) { - *data++ = IN32(id, I2CRXTX); - msg->len--; - len--; - } - - if (msg->len) { - len = (msg->len >= FIFO_SIZE) ? FIFO_SIZE - 1 - : msg->len - 1; - - OUT32(id, I2CFCR, FCR_TFRST | ((len & 0xf) << 4)); - } - - } else if (id->flags & IDF_SEND) { - if ((fsr & FSR_TEND) && (msg->len < 1)) { - if (id->flags & IDF_STOP) { - OUT32(id, I2CMCR, MCR_MIE | MCR_FSB); - } else { - id->status |= IDS_DONE; - /* keep the TEND bit: ctl holds SCL low - * until the setup for the next i2c_msg - * clears this bit. - */ - fsr &= ~FSR_TEND; - } - } - if (fsr & FSR_TDFE) { - while (msg->len && (IN32(id, I2CTFDR) < FIFO_SIZE)) { - OUT32(id, I2CRXTX, *data++); - msg->len--; - } - - if (msg->len < 1) { - fier &= ~FIER_TXIE; - OUT32(id, I2CFIER, fier); - } else { - len = (msg->len >= FIFO_SIZE) ? 2 : 0; - OUT32(id, I2CFCR, - FCR_RFRST | ((len & 3) << 2)); - } - } - } -out: - if (id->status & IDS_DONE) { - OUT32(id, I2CMIER, 0); - OUT32(id, I2CFIER, 0); - id->msg = NULL; - complete(&id->xfer_done); - } - /* clear status flags and ctrl resumes work */ - OUT32(id, I2CMSR, ~msr); - OUT32(id, I2CFSR, ~fsr); - OUT32(id, I2CSSR, 0); - - return IRQ_HANDLED; -} - - -/* prepare and start a master receive operation */ -static void sh7760_i2c_mrecv(struct cami2c *id) -{ - int len; - - id->flags |= IDF_RECV; - - /* set the slave addr reg; otherwise rcv wont work! */ - OUT32(id, I2CSAR, 0xfe); - OUT32(id, I2CMAR, (id->msg->addr << 1) | 1); - - /* adjust rx fifo trigger */ - if (id->msg->len >= FIFO_SIZE) - len = FIFO_SIZE - 1; /* trigger at fifo full */ - else - len = id->msg->len - 1; /* trigger before all received */ - - OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); - OUT32(id, I2CFCR, FCR_TFRST | ((len & 0xF) << 4)); - - OUT32(id, I2CMSR, 0); - OUT32(id, I2CMCR, MCR_MIE | MCR_ESG); - OUT32(id, I2CMIER, MIE_MNRE | MIE_MALE | MIE_MSTE | MIE_MATE); - OUT32(id, I2CFIER, FIER_RXIE); -} - -/* prepare and start a master send operation */ -static void sh7760_i2c_msend(struct cami2c *id) -{ - int len; - - id->flags |= IDF_SEND; - - /* set the slave addr reg; otherwise xmit wont work! */ - OUT32(id, I2CSAR, 0xfe); - OUT32(id, I2CMAR, (id->msg->addr << 1) | 0); - - /* adjust tx fifo trigger */ - if (id->msg->len >= FIFO_SIZE) - len = 2; /* trig: 2 bytes left in TX fifo */ - else - len = 0; /* trig: 8 bytes left in TX fifo */ - - OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); - OUT32(id, I2CFCR, FCR_RFRST | ((len & 3) << 2)); - - while (id->msg->len && IN32(id, I2CTFDR) < FIFO_SIZE) { - OUT32(id, I2CRXTX, *(id->msg->buf)); - (id->msg->len)--; - (id->msg->buf)++; - } - - OUT32(id, I2CMSR, 0); - OUT32(id, I2CMCR, MCR_MIE | MCR_ESG); - OUT32(id, I2CFSR, 0); - OUT32(id, I2CMIER, MIE_MNRE | MIE_MALE | MIE_MSTE | MIE_MATE); - OUT32(id, I2CFIER, FIER_TEIE | (id->msg->len ? FIER_TXIE : 0)); -} - -static inline int sh7760_i2c_busy_check(struct cami2c *id) -{ - return (IN32(id, I2CMCR) & MCR_FSDA); -} - -static int sh7760_i2c_master_xfer(struct i2c_adapter *adap, - struct i2c_msg *msgs, - int num) -{ - struct cami2c *id = adap->algo_data; - int i, retr; - - if (sh7760_i2c_busy_check(id)) { - dev_err(&adap->dev, "sh7760-i2c%d: bus busy!\n", adap->nr); - return -EBUSY; - } - - i = 0; - while (i < num) { - retr = adap->retries; -retry: - id->flags = ((i == (num-1)) ? IDF_STOP : 0); - id->status = 0; - id->msg = msgs; - init_completion(&id->xfer_done); - - if (msgs->flags & I2C_M_RD) - sh7760_i2c_mrecv(id); - else - sh7760_i2c_msend(id); - - wait_for_completion(&id->xfer_done); - - if (id->status == 0) { - num = -EIO; - break; - } - - if (id->status & IDS_NACK) { - /* wait a bit or i2c module stops working */ - mdelay(1); - num = -EREMOTEIO; - break; - } - - if (id->status & IDS_ARBLOST) { - if (retr--) { - mdelay(2); - goto retry; - } - num = -EREMOTEIO; - break; - } - - msgs++; - i++; - } - - id->msg = NULL; - id->flags = 0; - id->status = 0; - - OUT32(id, I2CMCR, 0); - OUT32(id, I2CMSR, 0); - OUT32(id, I2CMIER, 0); - OUT32(id, I2CFIER, 0); - - /* reset slave module registers too: master mode enables slave - * module for receive ops (ack, data). Without this reset, - * eternal bus activity might be reported after NACK / ARBLOST. - */ - OUT32(id, I2CSCR, 0); - OUT32(id, I2CSAR, 0); - OUT32(id, I2CSSR, 0); - - return num; -} - -static u32 sh7760_i2c_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK); -} - -static const struct i2c_algorithm sh7760_i2c_algo = { - .master_xfer = sh7760_i2c_master_xfer, - .functionality = sh7760_i2c_func, -}; - -/* calculate CCR register setting for a desired scl clock. SCL clock is - * derived from I2C module clock (iclk) which in turn is derived from - * peripheral module clock (mclk, usually around 33MHz): - * iclk = mclk/(CDF + 1). iclk must be < 20MHz. - * scl = iclk/(SCGD*8 + 20). - */ -static int calc_CCR(unsigned long scl_hz) -{ - struct clk *mclk; - unsigned long mck, m1, dff, odff, iclk; - signed char cdf, cdfm; - int scgd, scgdm, scgds; - - mclk = clk_get(NULL, "peripheral_clk"); - if (IS_ERR(mclk)) { - return PTR_ERR(mclk); - } else { - mck = mclk->rate; - clk_put(mclk); - } - - odff = scl_hz; - scgdm = cdfm = m1 = 0; - for (cdf = 3; cdf >= 0; cdf--) { - iclk = mck / (1 + cdf); - if (iclk >= 20000000) - continue; - scgds = ((iclk / scl_hz) - 20) >> 3; - for (scgd = scgds; (scgd < 63) && scgd <= scgds + 1; scgd++) { - m1 = iclk / (20 + (scgd << 3)); - dff = abs(scl_hz - m1); - if (dff < odff) { - odff = dff; - cdfm = cdf; - scgdm = scgd; - } - } - } - /* fail if more than 25% off of requested SCL */ - if (odff > (scl_hz >> 2)) - return -EINVAL; - - /* create a CCR register value */ - return ((scgdm << 2) | cdfm); -} - -static int sh7760_i2c_probe(struct platform_device *pdev) -{ - struct sh7760_i2c_platdata *pd; - struct resource *res; - struct cami2c *id; - int ret; - - pd = dev_get_platdata(&pdev->dev); - if (!pd) { - dev_err(&pdev->dev, "no platform_data!\n"); - ret = -ENODEV; - goto out0; - } - - id = kzalloc(sizeof(struct cami2c), GFP_KERNEL); - if (!id) { - dev_err(&pdev->dev, "no mem for private data\n"); - ret = -ENOMEM; - goto out0; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "no mmio resources\n"); - ret = -ENODEV; - goto out1; - } - - id->ioarea = request_mem_region(res->start, REGSIZE, pdev->name); - if (!id->ioarea) { - dev_err(&pdev->dev, "mmio already reserved\n"); - ret = -EBUSY; - goto out1; - } - - id->iobase = ioremap(res->start, REGSIZE); - if (!id->iobase) { - dev_err(&pdev->dev, "cannot ioremap\n"); - ret = -ENODEV; - goto out2; - } - - ret = platform_get_irq(pdev, 0); - if (ret < 0) - goto out3; - id->irq = ret; - - id->adap.nr = pdev->id; - id->adap.algo = &sh7760_i2c_algo; - id->adap.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - id->adap.retries = 3; - id->adap.algo_data = id; - id->adap.dev.parent = &pdev->dev; - snprintf(id->adap.name, sizeof(id->adap.name), - "SH7760 I2C at %08lx", (unsigned long)res->start); - - OUT32(id, I2CMCR, 0); - OUT32(id, I2CMSR, 0); - OUT32(id, I2CMIER, 0); - OUT32(id, I2CMAR, 0); - OUT32(id, I2CSIER, 0); - OUT32(id, I2CSAR, 0); - OUT32(id, I2CSCR, 0); - OUT32(id, I2CSSR, 0); - OUT32(id, I2CFIER, 0); - OUT32(id, I2CFCR, FCR_RFRST | FCR_TFRST); - OUT32(id, I2CFSR, 0); - - ret = calc_CCR(pd->speed_khz * 1000); - if (ret < 0) { - dev_err(&pdev->dev, "invalid SCL clock: %dkHz\n", - pd->speed_khz); - goto out3; - } - OUT32(id, I2CCCR, ret); - - if (request_irq(id->irq, sh7760_i2c_irq, 0, - SH7760_I2C_DEVNAME, id)) { - dev_err(&pdev->dev, "cannot get irq %d\n", id->irq); - ret = -EBUSY; - goto out3; - } - - ret = i2c_add_numbered_adapter(&id->adap); - if (ret < 0) - goto out4; - - platform_set_drvdata(pdev, id); - - dev_info(&pdev->dev, "%d kHz mmio %08x irq %d\n", - pd->speed_khz, res->start, id->irq); - - return 0; - -out4: - free_irq(id->irq, id); -out3: - iounmap(id->iobase); -out2: - release_resource(id->ioarea); - kfree(id->ioarea); -out1: - kfree(id); -out0: - return ret; -} - -static int sh7760_i2c_remove(struct platform_device *pdev) -{ - struct cami2c *id = platform_get_drvdata(pdev); - - i2c_del_adapter(&id->adap); - free_irq(id->irq, id); - iounmap(id->iobase); - release_resource(id->ioarea); - kfree(id->ioarea); - kfree(id); - - return 0; -} - -static struct platform_driver sh7760_i2c_drv = { - .driver = { - .name = SH7760_I2C_DEVNAME, - }, - .probe = sh7760_i2c_probe, - .remove = sh7760_i2c_remove, -}; - -module_platform_driver(sh7760_i2c_drv); - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("SH7760 I2C bus driver"); -MODULE_AUTHOR("Manuel Lauss "); From patchwork Fri Jan 13 06:23:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644796 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 407D4C678DD for ; Fri, 13 Jan 2023 06:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240895AbjAMG11 (ORCPT ); Fri, 13 Jan 2023 01:27:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240200AbjAMGZH (ORCPT ); Fri, 13 Jan 2023 01:25:07 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F136ADB3; Thu, 12 Jan 2023 22:24:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=JbdvnYG1GWIlI+mjR040Fz2HmYek241Q0TguaG7+sfY=; b=tzfdnSJqgAUXBCbR9jbeCtdG+k Wi2+ukoLPUYfwY4oRYG2G65CrLpHfCH7IZIGEmOBzuo2AOm57p4YVKhyyUSErQ/iIGMHRToCCfdf/ ktArnslU9c1GvDmR4UkceU2GUGqLzdTYlWtq3WsFqI46PrezV3almirhHOY1EgLXgwetLPHLE3dz4 2GoK8l9g2L+uO3MM192VOrBKVPmFiTXFEqVyPchcY6p43ebcOag5FCHnp6JVdvVjlJ96YLX/45Mi9 BCvOZVDckZcIaWRSsQl7roLaFbisbPzI3+C2vMQZUL7wC/PjrWG2okWzz8h9wGWMS/aXQsfNTjHUX 1o7HZ5UA==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDUB-000leH-Ap; Fri, 13 Jan 2023 06:24:19 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 10/22] input: remove sh_keysc Date: Fri, 13 Jan 2023 07:23:27 +0100 Message-Id: <20230113062339.1909087-11-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- drivers/input/keyboard/Kconfig | 10 - drivers/input/keyboard/Makefile | 1 - drivers/input/keyboard/sh_keysc.c | 334 ------------------------------ 3 files changed, 345 deletions(-) delete mode 100644 drivers/input/keyboard/sh_keysc.c diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 84490915ae4d5a..882ec5fef214ac 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -625,16 +625,6 @@ config KEYBOARD_SUNKBD To compile this driver as a module, choose M here: the module will be called sunkbd. -config KEYBOARD_SH_KEYSC - tristate "SuperH KEYSC keypad support" - depends on ARCH_SHMOBILE || COMPILE_TEST - help - Say Y here if you want to use a keypad attached to the KEYSC block - on SuperH processors such as sh7722 and sh7343. - - To compile this driver as a module, choose M here: the - module will be called sh_keysc. - config KEYBOARD_STMPE tristate "STMPE keypad support" depends on MFD_STMPE diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 5f67196bb2c1ea..8aba0b052b4504 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -60,7 +60,6 @@ obj-$(CONFIG_KEYBOARD_QT1050) += qt1050.o obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o obj-$(CONFIG_KEYBOARD_QT2160) += qt2160.o obj-$(CONFIG_KEYBOARD_SAMSUNG) += samsung-keypad.o -obj-$(CONFIG_KEYBOARD_SH_KEYSC) += sh_keysc.o obj-$(CONFIG_KEYBOARD_SNVS_PWRKEY) += snvs_pwrkey.o obj-$(CONFIG_KEYBOARD_SPEAR) += spear-keyboard.o obj-$(CONFIG_KEYBOARD_STMPE) += stmpe-keypad.o diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c deleted file mode 100644 index 2c00320f739fc1..00000000000000 --- a/drivers/input/keyboard/sh_keysc.c +++ /dev/null @@ -1,334 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * SuperH KEYSC Keypad Driver - * - * Copyright (C) 2008 Magnus Damm - * - * Based on gpio_keys.c, Copyright 2005 Phil Blundell - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const struct { - unsigned char kymd, keyout, keyin; -} sh_keysc_mode[] = { - [SH_KEYSC_MODE_1] = { 0, 6, 5 }, - [SH_KEYSC_MODE_2] = { 1, 5, 6 }, - [SH_KEYSC_MODE_3] = { 2, 4, 7 }, - [SH_KEYSC_MODE_4] = { 3, 6, 6 }, - [SH_KEYSC_MODE_5] = { 4, 6, 7 }, - [SH_KEYSC_MODE_6] = { 5, 8, 8 }, -}; - -struct sh_keysc_priv { - void __iomem *iomem_base; - DECLARE_BITMAP(last_keys, SH_KEYSC_MAXKEYS); - struct input_dev *input; - struct sh_keysc_info pdata; -}; - -#define KYCR1 0 -#define KYCR2 1 -#define KYINDR 2 -#define KYOUTDR 3 - -#define KYCR2_IRQ_LEVEL 0x10 -#define KYCR2_IRQ_DISABLED 0x00 - -static unsigned long sh_keysc_read(struct sh_keysc_priv *p, int reg_nr) -{ - return ioread16(p->iomem_base + (reg_nr << 2)); -} - -static void sh_keysc_write(struct sh_keysc_priv *p, int reg_nr, - unsigned long value) -{ - iowrite16(value, p->iomem_base + (reg_nr << 2)); -} - -static void sh_keysc_level_mode(struct sh_keysc_priv *p, - unsigned long keys_set) -{ - struct sh_keysc_info *pdata = &p->pdata; - - sh_keysc_write(p, KYOUTDR, 0); - sh_keysc_write(p, KYCR2, KYCR2_IRQ_LEVEL | (keys_set << 8)); - - if (pdata->kycr2_delay) - udelay(pdata->kycr2_delay); -} - -static void sh_keysc_map_dbg(struct device *dev, unsigned long *map, - const char *str) -{ - int k; - - for (k = 0; k < BITS_TO_LONGS(SH_KEYSC_MAXKEYS); k++) - dev_dbg(dev, "%s[%d] 0x%lx\n", str, k, map[k]); -} - -static irqreturn_t sh_keysc_isr(int irq, void *dev_id) -{ - struct platform_device *pdev = dev_id; - struct sh_keysc_priv *priv = platform_get_drvdata(pdev); - struct sh_keysc_info *pdata = &priv->pdata; - int keyout_nr = sh_keysc_mode[pdata->mode].keyout; - int keyin_nr = sh_keysc_mode[pdata->mode].keyin; - DECLARE_BITMAP(keys, SH_KEYSC_MAXKEYS); - DECLARE_BITMAP(keys0, SH_KEYSC_MAXKEYS); - DECLARE_BITMAP(keys1, SH_KEYSC_MAXKEYS); - unsigned char keyin_set, tmp; - int i, k, n; - - dev_dbg(&pdev->dev, "isr!\n"); - - bitmap_fill(keys1, SH_KEYSC_MAXKEYS); - bitmap_zero(keys0, SH_KEYSC_MAXKEYS); - - do { - bitmap_zero(keys, SH_KEYSC_MAXKEYS); - keyin_set = 0; - - sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED); - - for (i = 0; i < keyout_nr; i++) { - n = keyin_nr * i; - - /* drive one KEYOUT pin low, read KEYIN pins */ - sh_keysc_write(priv, KYOUTDR, 0xffff ^ (3 << (i * 2))); - udelay(pdata->delay); - tmp = sh_keysc_read(priv, KYINDR); - - /* set bit if key press has been detected */ - for (k = 0; k < keyin_nr; k++) { - if (tmp & (1 << k)) - __set_bit(n + k, keys); - } - - /* keep track of which KEYIN bits that have been set */ - keyin_set |= tmp ^ ((1 << keyin_nr) - 1); - } - - sh_keysc_level_mode(priv, keyin_set); - - bitmap_complement(keys, keys, SH_KEYSC_MAXKEYS); - bitmap_and(keys1, keys1, keys, SH_KEYSC_MAXKEYS); - bitmap_or(keys0, keys0, keys, SH_KEYSC_MAXKEYS); - - sh_keysc_map_dbg(&pdev->dev, keys, "keys"); - - } while (sh_keysc_read(priv, KYCR2) & 0x01); - - sh_keysc_map_dbg(&pdev->dev, priv->last_keys, "last_keys"); - sh_keysc_map_dbg(&pdev->dev, keys0, "keys0"); - sh_keysc_map_dbg(&pdev->dev, keys1, "keys1"); - - for (i = 0; i < SH_KEYSC_MAXKEYS; i++) { - k = pdata->keycodes[i]; - if (!k) - continue; - - if (test_bit(i, keys0) == test_bit(i, priv->last_keys)) - continue; - - if (test_bit(i, keys1) || test_bit(i, keys0)) { - input_event(priv->input, EV_KEY, k, 1); - __set_bit(i, priv->last_keys); - } - - if (!test_bit(i, keys1)) { - input_event(priv->input, EV_KEY, k, 0); - __clear_bit(i, priv->last_keys); - } - - } - input_sync(priv->input); - - return IRQ_HANDLED; -} - -static int sh_keysc_probe(struct platform_device *pdev) -{ - struct sh_keysc_priv *priv; - struct sh_keysc_info *pdata; - struct resource *res; - struct input_dev *input; - int i; - int irq, error; - - if (!dev_get_platdata(&pdev->dev)) { - dev_err(&pdev->dev, "no platform data defined\n"); - error = -EINVAL; - goto err0; - } - - error = -ENXIO; - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { - dev_err(&pdev->dev, "failed to get I/O memory\n"); - goto err0; - } - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - goto err0; - - priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (priv == NULL) { - dev_err(&pdev->dev, "failed to allocate driver data\n"); - error = -ENOMEM; - goto err0; - } - - platform_set_drvdata(pdev, priv); - memcpy(&priv->pdata, dev_get_platdata(&pdev->dev), sizeof(priv->pdata)); - pdata = &priv->pdata; - - priv->iomem_base = ioremap(res->start, resource_size(res)); - if (priv->iomem_base == NULL) { - dev_err(&pdev->dev, "failed to remap I/O memory\n"); - error = -ENXIO; - goto err1; - } - - priv->input = input_allocate_device(); - if (!priv->input) { - dev_err(&pdev->dev, "failed to allocate input device\n"); - error = -ENOMEM; - goto err2; - } - - input = priv->input; - input->evbit[0] = BIT_MASK(EV_KEY); - - input->name = pdev->name; - input->phys = "sh-keysc-keys/input0"; - input->dev.parent = &pdev->dev; - - input->id.bustype = BUS_HOST; - input->id.vendor = 0x0001; - input->id.product = 0x0001; - input->id.version = 0x0100; - - input->keycode = pdata->keycodes; - input->keycodesize = sizeof(pdata->keycodes[0]); - input->keycodemax = ARRAY_SIZE(pdata->keycodes); - - error = request_threaded_irq(irq, NULL, sh_keysc_isr, IRQF_ONESHOT, - dev_name(&pdev->dev), pdev); - if (error) { - dev_err(&pdev->dev, "failed to request IRQ\n"); - goto err3; - } - - for (i = 0; i < SH_KEYSC_MAXKEYS; i++) - __set_bit(pdata->keycodes[i], input->keybit); - __clear_bit(KEY_RESERVED, input->keybit); - - error = input_register_device(input); - if (error) { - dev_err(&pdev->dev, "failed to register input device\n"); - goto err4; - } - - pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(&pdev->dev); - - sh_keysc_write(priv, KYCR1, (sh_keysc_mode[pdata->mode].kymd << 8) | - pdata->scan_timing); - sh_keysc_level_mode(priv, 0); - - device_init_wakeup(&pdev->dev, 1); - - return 0; - - err4: - free_irq(irq, pdev); - err3: - input_free_device(input); - err2: - iounmap(priv->iomem_base); - err1: - kfree(priv); - err0: - return error; -} - -static int sh_keysc_remove(struct platform_device *pdev) -{ - struct sh_keysc_priv *priv = platform_get_drvdata(pdev); - - sh_keysc_write(priv, KYCR2, KYCR2_IRQ_DISABLED); - - input_unregister_device(priv->input); - free_irq(platform_get_irq(pdev, 0), pdev); - iounmap(priv->iomem_base); - - pm_runtime_put_sync(&pdev->dev); - pm_runtime_disable(&pdev->dev); - - kfree(priv); - - return 0; -} - -static int sh_keysc_suspend(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct sh_keysc_priv *priv = platform_get_drvdata(pdev); - int irq = platform_get_irq(pdev, 0); - unsigned short value; - - value = sh_keysc_read(priv, KYCR1); - - if (device_may_wakeup(dev)) { - sh_keysc_write(priv, KYCR1, value | 0x80); - enable_irq_wake(irq); - } else { - sh_keysc_write(priv, KYCR1, value & ~0x80); - pm_runtime_put_sync(dev); - } - - return 0; -} - -static int sh_keysc_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - int irq = platform_get_irq(pdev, 0); - - if (device_may_wakeup(dev)) - disable_irq_wake(irq); - else - pm_runtime_get_sync(dev); - - return 0; -} - -static DEFINE_SIMPLE_DEV_PM_OPS(sh_keysc_dev_pm_ops, - sh_keysc_suspend, sh_keysc_resume); - -static struct platform_driver sh_keysc_device_driver = { - .probe = sh_keysc_probe, - .remove = sh_keysc_remove, - .driver = { - .name = "sh_keysc", - .pm = pm_sleep_ptr(&sh_keysc_dev_pm_ops), - } -}; -module_platform_driver(sh_keysc_device_driver); - -MODULE_AUTHOR("Magnus Damm"); -MODULE_DESCRIPTION("SuperH KEYSC Keypad Driver"); -MODULE_LICENSE("GPL"); From patchwork Fri Jan 13 06:23:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644792 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C770EC54EBD for ; Fri, 13 Jan 2023 06:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241358AbjAMGaY (ORCPT ); Fri, 13 Jan 2023 01:30:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240696AbjAMG0G (ORCPT ); Fri, 13 Jan 2023 01:26:06 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 681155A880; Thu, 12 Jan 2023 22:24:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=brkgyM1hhrmjLwT1BCvS491OM9ZvmSvWuQcY6ZdmaEQ=; b=rclg5IcyZx3hAYAW2A82gKgG/R 9h9Oe/wM1Koo+NmcZ4yMIJIFj+qyIun0yWyAuormOj2yAyWxmpqiP2tOTjglLnHiXw+LO8ETgIdA+ 5Svhx7nVkyRr8shQSGKZC980O+hinT+yIkJMia9iivbaAqpxScAjdfS1ylAfFTuFfEpPajKlizKuC x920Cmh9IN6hilV+vdW649ilBNPtNcRIhR92SLyVFpjckwWhuUlUQEzckeqR1pXS3MdV0ZyVfntjY 4ZjNun8OKq1jiBsWb6I8b5g9mXdhx5n98DESlAo/jfRw7Kht5JW4J78GkDbW2pZIH+YhQxqch531J NCRDTDXw==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDUT-000lua-TT; Fri, 13 Jan 2023 06:24:38 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 15/22] spi: remove spi-sh Date: Fri, 13 Jan 2023 07:23:32 +0100 Message-Id: <20230113062339.1909087-16-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- drivers/spi/Kconfig | 6 - drivers/spi/Makefile | 1 - drivers/spi/spi-sh.c | 474 ------------------------------------------- 3 files changed, 481 deletions(-) delete mode 100644 drivers/spi/spi-sh.c diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 2c5226adf5e1d3..7508dcef909c78 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -882,12 +882,6 @@ config SPI_SH_MSIOF help SPI driver for SuperH and SH Mobile MSIOF blocks. -config SPI_SH - tristate "SuperH SPI controller" - depends on SUPERH || COMPILE_TEST - help - SPI driver for SuperH SPI blocks. - config SPI_SH_SCI tristate "SuperH SCI SPI controller" depends on SUPERH diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index be9ba40ef8d03d..342a7eb5181c9b 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -116,7 +116,6 @@ obj-$(CONFIG_SPI_S3C24XX) += spi-s3c24xx-hw.o spi-s3c24xx-hw-y := spi-s3c24xx.o obj-$(CONFIG_SPI_S3C64XX) += spi-s3c64xx.o obj-$(CONFIG_SPI_SC18IS602) += spi-sc18is602.o -obj-$(CONFIG_SPI_SH) += spi-sh.o obj-$(CONFIG_SPI_SH_HSPI) += spi-sh-hspi.o obj-$(CONFIG_SPI_SH_MSIOF) += spi-sh-msiof.o obj-$(CONFIG_SPI_SH_SCI) += spi-sh-sci.o diff --git a/drivers/spi/spi-sh.c b/drivers/spi/spi-sh.c deleted file mode 100644 index 3e72fad99adfd4..00000000000000 --- a/drivers/spi/spi-sh.c +++ /dev/null @@ -1,474 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * SH SPI bus driver - * - * Copyright (C) 2011 Renesas Solutions Corp. - * - * Based on pxa2xx_spi.c: - * Copyright (C) 2005 Stephen Street / StreetFire Sound Labs - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SPI_SH_TBR 0x00 -#define SPI_SH_RBR 0x00 -#define SPI_SH_CR1 0x08 -#define SPI_SH_CR2 0x10 -#define SPI_SH_CR3 0x18 -#define SPI_SH_CR4 0x20 -#define SPI_SH_CR5 0x28 - -/* CR1 */ -#define SPI_SH_TBE 0x80 -#define SPI_SH_TBF 0x40 -#define SPI_SH_RBE 0x20 -#define SPI_SH_RBF 0x10 -#define SPI_SH_PFONRD 0x08 -#define SPI_SH_SSDB 0x04 -#define SPI_SH_SSD 0x02 -#define SPI_SH_SSA 0x01 - -/* CR2 */ -#define SPI_SH_RSTF 0x80 -#define SPI_SH_LOOPBK 0x40 -#define SPI_SH_CPOL 0x20 -#define SPI_SH_CPHA 0x10 -#define SPI_SH_L1M0 0x08 - -/* CR3 */ -#define SPI_SH_MAX_BYTE 0xFF - -/* CR4 */ -#define SPI_SH_TBEI 0x80 -#define SPI_SH_TBFI 0x40 -#define SPI_SH_RBEI 0x20 -#define SPI_SH_RBFI 0x10 -#define SPI_SH_WPABRT 0x04 -#define SPI_SH_SSS 0x01 - -/* CR8 */ -#define SPI_SH_P1L0 0x80 -#define SPI_SH_PP1L0 0x40 -#define SPI_SH_MUXI 0x20 -#define SPI_SH_MUXIRQ 0x10 - -#define SPI_SH_FIFO_SIZE 32 -#define SPI_SH_SEND_TIMEOUT (3 * HZ) -#define SPI_SH_RECEIVE_TIMEOUT (HZ >> 3) - -#undef DEBUG - -struct spi_sh_data { - void __iomem *addr; - int irq; - struct spi_master *master; - unsigned long cr1; - wait_queue_head_t wait; - int width; -}; - -static void spi_sh_write(struct spi_sh_data *ss, unsigned long data, - unsigned long offset) -{ - if (ss->width == 8) - iowrite8(data, ss->addr + (offset >> 2)); - else if (ss->width == 32) - iowrite32(data, ss->addr + offset); -} - -static unsigned long spi_sh_read(struct spi_sh_data *ss, unsigned long offset) -{ - if (ss->width == 8) - return ioread8(ss->addr + (offset >> 2)); - else if (ss->width == 32) - return ioread32(ss->addr + offset); - else - return 0; -} - -static void spi_sh_set_bit(struct spi_sh_data *ss, unsigned long val, - unsigned long offset) -{ - unsigned long tmp; - - tmp = spi_sh_read(ss, offset); - tmp |= val; - spi_sh_write(ss, tmp, offset); -} - -static void spi_sh_clear_bit(struct spi_sh_data *ss, unsigned long val, - unsigned long offset) -{ - unsigned long tmp; - - tmp = spi_sh_read(ss, offset); - tmp &= ~val; - spi_sh_write(ss, tmp, offset); -} - -static void clear_fifo(struct spi_sh_data *ss) -{ - spi_sh_set_bit(ss, SPI_SH_RSTF, SPI_SH_CR2); - spi_sh_clear_bit(ss, SPI_SH_RSTF, SPI_SH_CR2); -} - -static int spi_sh_wait_receive_buffer(struct spi_sh_data *ss) -{ - int timeout = 100000; - - while (spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_RBE) { - udelay(10); - if (timeout-- < 0) - return -ETIMEDOUT; - } - return 0; -} - -static int spi_sh_wait_write_buffer_empty(struct spi_sh_data *ss) -{ - int timeout = 100000; - - while (!(spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_TBE)) { - udelay(10); - if (timeout-- < 0) - return -ETIMEDOUT; - } - return 0; -} - -static int spi_sh_send(struct spi_sh_data *ss, struct spi_message *mesg, - struct spi_transfer *t) -{ - int i, retval = 0; - int remain = t->len; - int cur_len; - unsigned char *data; - long ret; - - if (t->len) - spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); - - data = (unsigned char *)t->tx_buf; - while (remain > 0) { - cur_len = min(SPI_SH_FIFO_SIZE, remain); - for (i = 0; i < cur_len && - !(spi_sh_read(ss, SPI_SH_CR4) & - SPI_SH_WPABRT) && - !(spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_TBF); - i++) - spi_sh_write(ss, (unsigned long)data[i], SPI_SH_TBR); - - if (spi_sh_read(ss, SPI_SH_CR4) & SPI_SH_WPABRT) { - /* Abort SPI operation */ - spi_sh_set_bit(ss, SPI_SH_WPABRT, SPI_SH_CR4); - retval = -EIO; - break; - } - - cur_len = i; - - remain -= cur_len; - data += cur_len; - - if (remain > 0) { - ss->cr1 &= ~SPI_SH_TBE; - spi_sh_set_bit(ss, SPI_SH_TBE, SPI_SH_CR4); - ret = wait_event_interruptible_timeout(ss->wait, - ss->cr1 & SPI_SH_TBE, - SPI_SH_SEND_TIMEOUT); - if (ret == 0 && !(ss->cr1 & SPI_SH_TBE)) { - printk(KERN_ERR "%s: timeout\n", __func__); - return -ETIMEDOUT; - } - } - } - - if (list_is_last(&t->transfer_list, &mesg->transfers)) { - spi_sh_clear_bit(ss, SPI_SH_SSD | SPI_SH_SSDB, SPI_SH_CR1); - spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); - - ss->cr1 &= ~SPI_SH_TBE; - spi_sh_set_bit(ss, SPI_SH_TBE, SPI_SH_CR4); - ret = wait_event_interruptible_timeout(ss->wait, - ss->cr1 & SPI_SH_TBE, - SPI_SH_SEND_TIMEOUT); - if (ret == 0 && (ss->cr1 & SPI_SH_TBE)) { - printk(KERN_ERR "%s: timeout\n", __func__); - return -ETIMEDOUT; - } - } - - return retval; -} - -static int spi_sh_receive(struct spi_sh_data *ss, struct spi_message *mesg, - struct spi_transfer *t) -{ - int i; - int remain = t->len; - int cur_len; - unsigned char *data; - long ret; - - if (t->len > SPI_SH_MAX_BYTE) - spi_sh_write(ss, SPI_SH_MAX_BYTE, SPI_SH_CR3); - else - spi_sh_write(ss, t->len, SPI_SH_CR3); - - spi_sh_clear_bit(ss, SPI_SH_SSD | SPI_SH_SSDB, SPI_SH_CR1); - spi_sh_set_bit(ss, SPI_SH_SSA, SPI_SH_CR1); - - spi_sh_wait_write_buffer_empty(ss); - - data = (unsigned char *)t->rx_buf; - while (remain > 0) { - if (remain >= SPI_SH_FIFO_SIZE) { - ss->cr1 &= ~SPI_SH_RBF; - spi_sh_set_bit(ss, SPI_SH_RBF, SPI_SH_CR4); - ret = wait_event_interruptible_timeout(ss->wait, - ss->cr1 & SPI_SH_RBF, - SPI_SH_RECEIVE_TIMEOUT); - if (ret == 0 && - spi_sh_read(ss, SPI_SH_CR1) & SPI_SH_RBE) { - printk(KERN_ERR "%s: timeout\n", __func__); - return -ETIMEDOUT; - } - } - - cur_len = min(SPI_SH_FIFO_SIZE, remain); - for (i = 0; i < cur_len; i++) { - if (spi_sh_wait_receive_buffer(ss)) - break; - data[i] = (unsigned char)spi_sh_read(ss, SPI_SH_RBR); - } - - remain -= cur_len; - data += cur_len; - } - - /* deassert CS when SPI is receiving. */ - if (t->len > SPI_SH_MAX_BYTE) { - clear_fifo(ss); - spi_sh_write(ss, 1, SPI_SH_CR3); - } else { - spi_sh_write(ss, 0, SPI_SH_CR3); - } - - return 0; -} - -static int spi_sh_transfer_one_message(struct spi_controller *ctlr, - struct spi_message *mesg) -{ - struct spi_sh_data *ss = spi_controller_get_devdata(ctlr); - struct spi_transfer *t; - int ret; - - pr_debug("%s: enter\n", __func__); - - spi_sh_clear_bit(ss, SPI_SH_SSA, SPI_SH_CR1); - - list_for_each_entry(t, &mesg->transfers, transfer_list) { - pr_debug("tx_buf = %p, rx_buf = %p\n", - t->tx_buf, t->rx_buf); - pr_debug("len = %d, delay.value = %d\n", - t->len, t->delay.value); - - if (t->tx_buf) { - ret = spi_sh_send(ss, mesg, t); - if (ret < 0) - goto error; - } - if (t->rx_buf) { - ret = spi_sh_receive(ss, mesg, t); - if (ret < 0) - goto error; - } - mesg->actual_length += t->len; - } - - mesg->status = 0; - spi_finalize_current_message(ctlr); - - clear_fifo(ss); - spi_sh_set_bit(ss, SPI_SH_SSD, SPI_SH_CR1); - udelay(100); - - spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, - SPI_SH_CR1); - - clear_fifo(ss); - - return 0; - - error: - mesg->status = ret; - spi_finalize_current_message(ctlr); - if (mesg->complete) - mesg->complete(mesg->context); - - spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, - SPI_SH_CR1); - clear_fifo(ss); - - return ret; -} - -static int spi_sh_setup(struct spi_device *spi) -{ - struct spi_sh_data *ss = spi_master_get_devdata(spi->master); - - pr_debug("%s: enter\n", __func__); - - spi_sh_write(ss, 0xfe, SPI_SH_CR1); /* SPI sycle stop */ - spi_sh_write(ss, 0x00, SPI_SH_CR1); /* CR1 init */ - spi_sh_write(ss, 0x00, SPI_SH_CR3); /* CR3 init */ - - clear_fifo(ss); - - /* 1/8 clock */ - spi_sh_write(ss, spi_sh_read(ss, SPI_SH_CR2) | 0x07, SPI_SH_CR2); - udelay(10); - - return 0; -} - -static void spi_sh_cleanup(struct spi_device *spi) -{ - struct spi_sh_data *ss = spi_master_get_devdata(spi->master); - - pr_debug("%s: enter\n", __func__); - - spi_sh_clear_bit(ss, SPI_SH_SSA | SPI_SH_SSDB | SPI_SH_SSD, - SPI_SH_CR1); -} - -static irqreturn_t spi_sh_irq(int irq, void *_ss) -{ - struct spi_sh_data *ss = (struct spi_sh_data *)_ss; - unsigned long cr1; - - cr1 = spi_sh_read(ss, SPI_SH_CR1); - if (cr1 & SPI_SH_TBE) - ss->cr1 |= SPI_SH_TBE; - if (cr1 & SPI_SH_TBF) - ss->cr1 |= SPI_SH_TBF; - if (cr1 & SPI_SH_RBE) - ss->cr1 |= SPI_SH_RBE; - if (cr1 & SPI_SH_RBF) - ss->cr1 |= SPI_SH_RBF; - - if (ss->cr1) { - spi_sh_clear_bit(ss, ss->cr1, SPI_SH_CR4); - wake_up(&ss->wait); - } - - return IRQ_HANDLED; -} - -static int spi_sh_remove(struct platform_device *pdev) -{ - struct spi_sh_data *ss = platform_get_drvdata(pdev); - - spi_unregister_master(ss->master); - free_irq(ss->irq, ss); - - return 0; -} - -static int spi_sh_probe(struct platform_device *pdev) -{ - struct resource *res; - struct spi_master *master; - struct spi_sh_data *ss; - int ret, irq; - - /* get base addr */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (unlikely(res == NULL)) { - dev_err(&pdev->dev, "invalid resource\n"); - return -EINVAL; - } - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; - - master = devm_spi_alloc_master(&pdev->dev, sizeof(struct spi_sh_data)); - if (master == NULL) { - dev_err(&pdev->dev, "spi_alloc_master error.\n"); - return -ENOMEM; - } - - ss = spi_master_get_devdata(master); - platform_set_drvdata(pdev, ss); - - switch (res->flags & IORESOURCE_MEM_TYPE_MASK) { - case IORESOURCE_MEM_8BIT: - ss->width = 8; - break; - case IORESOURCE_MEM_32BIT: - ss->width = 32; - break; - default: - dev_err(&pdev->dev, "No support width\n"); - return -ENODEV; - } - ss->irq = irq; - ss->master = master; - ss->addr = devm_ioremap(&pdev->dev, res->start, resource_size(res)); - if (ss->addr == NULL) { - dev_err(&pdev->dev, "ioremap error.\n"); - return -ENOMEM; - } - init_waitqueue_head(&ss->wait); - - ret = request_irq(irq, spi_sh_irq, 0, "spi_sh", ss); - if (ret < 0) { - dev_err(&pdev->dev, "request_irq error\n"); - return ret; - } - - master->num_chipselect = 2; - master->bus_num = pdev->id; - master->setup = spi_sh_setup; - master->transfer_one_message = spi_sh_transfer_one_message; - master->cleanup = spi_sh_cleanup; - - ret = spi_register_master(master); - if (ret < 0) { - printk(KERN_ERR "spi_register_master error.\n"); - goto error3; - } - - return 0; - - error3: - free_irq(irq, ss); - return ret; -} - -static struct platform_driver spi_sh_driver = { - .probe = spi_sh_probe, - .remove = spi_sh_remove, - .driver = { - .name = "sh_spi", - }, -}; -module_platform_driver(spi_sh_driver); - -MODULE_DESCRIPTION("SH SPI bus driver"); -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Yoshihiro Shimoda"); -MODULE_ALIAS("platform:sh_spi"); From patchwork Fri Jan 13 06:23:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644790 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA795C54EBE for ; Fri, 13 Jan 2023 06:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241380AbjAMGal (ORCPT ); Fri, 13 Jan 2023 01:30:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240759AbjAMG0u (ORCPT ); Fri, 13 Jan 2023 01:26:50 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF2B55BA16; Thu, 12 Jan 2023 22:24:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=UA3Wx2g8+e+Fb1QaXEWK5OP24rFFtFCQfYxWGC/7x1s=; b=NgPhSrF34f2zcVzS0tgAL6SgbE zRtNJPHFDmvbOdI3GA8GgIGbclB1ExF6UYx3/DOow16PdNqNFgArlB6/7DeVG8QXv9klWNTE8z76X RxDxcxbzx1a5/02Maj5eBCzCASpahQtLWA2keIRijYtli8Z/MLfSY9hHS0VU+LPEPmMxQpGIWA7ec 3SfxmuGWVMyYB1NxTK6cbQ94YpmydUsc9sm9uGHn71o4BEIUZobj8AWNqdv6668P1fZZLhJM/SiY9 6mtAfE5wns/6VQmwdJIZFuUB6Mw5tHauSYYU3JYD4h2ywkt/BsuHr9keJXWSSnIiIpSqtpoa6ATWh Wd4bfZDA==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDUc-000m1U-Nf; Fri, 13 Jan 2023 06:24:47 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 18/22] usb: remove ehci-sh Date: Fri, 13 Jan 2023 07:23:35 +0100 Message-Id: <20230113062339.1909087-19-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- drivers/usb/host/Kconfig | 7 -- drivers/usb/host/ehci-hcd.c | 7 -- drivers/usb/host/ehci-sh.c | 182 ------------------------------------ 3 files changed, 196 deletions(-) delete mode 100644 drivers/usb/host/ehci-sh.c diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index ca5f657c092cf4..ddd8b798626caf 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -279,13 +279,6 @@ config USB_EHCI_HCD_PPC_OF Enables support for the USB controller present on the PowerPC OpenFirmware platform bus. -config USB_EHCI_SH - bool "EHCI support for SuperH USB controller" - depends on SUPERH || COMPILE_TEST - help - Enables support for the on-chip EHCI controller on the SuperH. - If you use the PCI EHCI controller, this option is not necessary. - config USB_EHCI_EXYNOS tristate "EHCI support for Samsung S5P/Exynos SoC Series" depends on ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a1930db0da1c3c..e6dfef3492aabe 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1309,10 +1309,6 @@ MODULE_DESCRIPTION(DRIVER_DESC); MODULE_AUTHOR (DRIVER_AUTHOR); MODULE_LICENSE ("GPL"); -#ifdef CONFIG_USB_EHCI_SH -#include "ehci-sh.c" -#endif - #ifdef CONFIG_PPC_PS3 #include "ehci-ps3.c" #endif @@ -1330,9 +1326,6 @@ MODULE_LICENSE ("GPL"); #endif static struct platform_driver * const platform_drivers[] = { -#ifdef CONFIG_USB_EHCI_SH - &ehci_hcd_sh_driver, -#endif #ifdef CONFIG_USB_EHCI_HCD_PPC_OF &ehci_hcd_ppc_of_driver, #endif diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c deleted file mode 100644 index c25c51d26f2603..00000000000000 --- a/drivers/usb/host/ehci-sh.c +++ /dev/null @@ -1,182 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * SuperH EHCI host controller driver - * - * Copyright (C) 2010 Paul Mundt - * - * Based on ohci-sh.c and ehci-atmel.c. - */ -#include -#include - -struct ehci_sh_priv { - struct clk *iclk, *fclk; - struct usb_hcd *hcd; -}; - -static int ehci_sh_reset(struct usb_hcd *hcd) -{ - struct ehci_hcd *ehci = hcd_to_ehci(hcd); - - ehci->caps = hcd->regs; - - return ehci_setup(hcd); -} - -static const struct hc_driver ehci_sh_hc_driver = { - .description = hcd_name, - .product_desc = "SuperH EHCI", - .hcd_priv_size = sizeof(struct ehci_hcd), - - /* - * generic hardware linkage - */ - .irq = ehci_irq, - .flags = HCD_USB2 | HCD_DMA | HCD_MEMORY | HCD_BH, - - /* - * basic lifecycle operations - */ - .reset = ehci_sh_reset, - .start = ehci_run, - .stop = ehci_stop, - .shutdown = ehci_shutdown, - - /* - * managing i/o requests and associated device resources - */ - .urb_enqueue = ehci_urb_enqueue, - .urb_dequeue = ehci_urb_dequeue, - .endpoint_disable = ehci_endpoint_disable, - .endpoint_reset = ehci_endpoint_reset, - - /* - * scheduling support - */ - .get_frame_number = ehci_get_frame, - - /* - * root hub support - */ - .hub_status_data = ehci_hub_status_data, - .hub_control = ehci_hub_control, - -#ifdef CONFIG_PM - .bus_suspend = ehci_bus_suspend, - .bus_resume = ehci_bus_resume, -#endif - - .relinquish_port = ehci_relinquish_port, - .port_handed_over = ehci_port_handed_over, - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, -}; - -static int ehci_hcd_sh_probe(struct platform_device *pdev) -{ - struct resource *res; - struct ehci_sh_priv *priv; - struct usb_hcd *hcd; - int irq, ret; - - if (usb_disabled()) - return -ENODEV; - - irq = platform_get_irq(pdev, 0); - if (irq <= 0) { - ret = -ENODEV; - goto fail_create_hcd; - } - - /* initialize hcd */ - hcd = usb_create_hcd(&ehci_sh_hc_driver, &pdev->dev, - dev_name(&pdev->dev)); - if (!hcd) { - ret = -ENOMEM; - goto fail_create_hcd; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - hcd->regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(hcd->regs)) { - ret = PTR_ERR(hcd->regs); - goto fail_request_resource; - } - hcd->rsrc_start = res->start; - hcd->rsrc_len = resource_size(res); - - priv = devm_kzalloc(&pdev->dev, sizeof(struct ehci_sh_priv), - GFP_KERNEL); - if (!priv) { - ret = -ENOMEM; - goto fail_request_resource; - } - - /* These are optional, we don't care if they fail */ - priv->fclk = devm_clk_get(&pdev->dev, "usb_fck"); - if (IS_ERR(priv->fclk)) - priv->fclk = NULL; - - priv->iclk = devm_clk_get(&pdev->dev, "usb_ick"); - if (IS_ERR(priv->iclk)) - priv->iclk = NULL; - - clk_enable(priv->fclk); - clk_enable(priv->iclk); - - ret = usb_add_hcd(hcd, irq, IRQF_SHARED); - if (ret != 0) { - dev_err(&pdev->dev, "Failed to add hcd"); - goto fail_add_hcd; - } - device_wakeup_enable(hcd->self.controller); - - priv->hcd = hcd; - platform_set_drvdata(pdev, priv); - - return ret; - -fail_add_hcd: - clk_disable(priv->iclk); - clk_disable(priv->fclk); - -fail_request_resource: - usb_put_hcd(hcd); -fail_create_hcd: - dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), ret); - - return ret; -} - -static int ehci_hcd_sh_remove(struct platform_device *pdev) -{ - struct ehci_sh_priv *priv = platform_get_drvdata(pdev); - struct usb_hcd *hcd = priv->hcd; - - usb_remove_hcd(hcd); - usb_put_hcd(hcd); - - clk_disable(priv->fclk); - clk_disable(priv->iclk); - - return 0; -} - -static void ehci_hcd_sh_shutdown(struct platform_device *pdev) -{ - struct ehci_sh_priv *priv = platform_get_drvdata(pdev); - struct usb_hcd *hcd = priv->hcd; - - if (hcd->driver->shutdown) - hcd->driver->shutdown(hcd); -} - -static struct platform_driver ehci_hcd_sh_driver = { - .probe = ehci_hcd_sh_probe, - .remove = ehci_hcd_sh_remove, - .shutdown = ehci_hcd_sh_shutdown, - .driver = { - .name = "sh_ehci", - }, -}; - -MODULE_ALIAS("platform:sh_ehci"); From patchwork Fri Jan 13 06:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644794 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66F83C678DF for ; Fri, 13 Jan 2023 06:30:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230413AbjAMGaN (ORCPT ); Fri, 13 Jan 2023 01:30:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240774AbjAMG0x (ORCPT ); Fri, 13 Jan 2023 01:26:53 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3459D5BA1B; Thu, 12 Jan 2023 22:25:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=rVY6HIQ2gsxs3KQUArU5ZItu96aUMGaCnBVCkBolLI4=; b=ols2YTxab2DrJGg/MQYB8ngvh4 2GoCDaxIyG+UAHbvOUlJ/MTpkGQk/zC0l52K8fRdGCh6xMOqaRHM59+Har1MJwW5GZ1oIM8J1v6cl v924PZCU1h7/cErrZGJLDf2ruP988FQahKVzQEBHwrRCAM/xOd4ablpxwpIBi2Dzk7vQ1BDy4V+TQ dqloToyE27AJgXr+JXEIwOPYaAaoOKLxFMcUXxJ57SFcQFrHFAGomvQDIv8XCOuHCX2Y1kobqXrc2 ty++rGr4ThHs7RrC4NZXSNWldVwrTlxjqdnliCAjLPmDCbm4H8GwMbq6rM7kE4zp74SS2ufg5ameo Hg6kc6cw==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDUf-000m3E-Fe; Fri, 13 Jan 2023 06:24:49 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 19/22] fbdev: remove sh7760fb Date: Fri, 13 Jan 2023 07:23:36 +0100 Message-Id: <20230113062339.1909087-20-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- drivers/video/fbdev/Kconfig | 17 +- drivers/video/fbdev/Makefile | 1 - drivers/video/fbdev/sh7760fb.c | 587 --------------------------------- 3 files changed, 1 insertion(+), 604 deletions(-) delete mode 100644 drivers/video/fbdev/sh7760fb.c diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index b2bed599e6c6ea..cba0ba512a6ddb 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -1861,7 +1861,7 @@ config FB_W100 config FB_SH_MOBILE_LCDC tristate "SuperH Mobile LCDC framebuffer support" depends on FB && HAVE_CLK && HAS_IOMEM - depends on SUPERH || ARCH_RENESAS || COMPILE_TEST + depends on ARCH_RENESAS || COMPILE_TEST select FB_SYS_FILLRECT select FB_SYS_COPYAREA select FB_SYS_IMAGEBLIT @@ -2048,21 +2048,6 @@ config FB_COBALT tristate "Cobalt server LCD frame buffer support" depends on FB && MIPS_COBALT -config FB_SH7760 - bool "SH7760/SH7763/SH7720/SH7721 LCDC support" - depends on FB && (CPU_SUBTYPE_SH7760 || CPU_SUBTYPE_SH7763 \ - || CPU_SUBTYPE_SH7720 || CPU_SUBTYPE_SH7721) - select FB_CFB_FILLRECT - select FB_CFB_COPYAREA - select FB_CFB_IMAGEBLIT - help - Support for the SH7760/SH7763/SH7720/SH7721 integrated - (D)STN/TFT LCD Controller. - Supports display resolutions up to 1024x1024 pixel, grayscale and - color operation, with depths ranging from 1 bpp to 8 bpp monochrome - and 8, 15 or 16 bpp color; 90 degrees clockwise display rotation for - panels <= 320 pixel horizontal resolution. - config FB_DA8XX tristate "DA8xx/OMAP-L1xx/AM335x Framebuffer support" depends on FB && HAVE_CLK && HAS_IOMEM diff --git a/drivers/video/fbdev/Makefile b/drivers/video/fbdev/Makefile index 7795c4126706fd..9941a30522b4b3 100644 --- a/drivers/video/fbdev/Makefile +++ b/drivers/video/fbdev/Makefile @@ -97,7 +97,6 @@ obj-$(CONFIG_FB_MAXINE) += maxinefb.o obj-$(CONFIG_FB_METRONOME) += metronomefb.o obj-$(CONFIG_FB_BROADSHEET) += broadsheetfb.o obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o -obj-$(CONFIG_FB_SH7760) += sh7760fb.o obj-$(CONFIG_FB_IMX) += imxfb.o obj-$(CONFIG_FB_S3C) += s3c-fb.o obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o diff --git a/drivers/video/fbdev/sh7760fb.c b/drivers/video/fbdev/sh7760fb.c deleted file mode 100644 index 5978a892123226..00000000000000 --- a/drivers/video/fbdev/sh7760fb.c +++ /dev/null @@ -1,587 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * SH7760/SH7763 LCDC Framebuffer driver. - * - * (c) 2006-2008 MSC Vertriebsges.m.b.H., - * Manuel Lauss - * (c) 2008 Nobuhiro Iwamatsu - * - * PLEASE HAVE A LOOK AT Documentation/fb/sh7760fb.rst! - * - * Thanks to Siegfried Schaefer - * for his original source and testing! - * - * sh7760_setcolreg get from drivers/video/sh_mobile_lcdcfb.c - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct sh7760fb_par { - void __iomem *base; - int irq; - - struct sh7760fb_platdata *pd; /* display information */ - - dma_addr_t fbdma; /* physical address */ - - int rot; /* rotation enabled? */ - - u32 pseudo_palette[16]; - - struct platform_device *dev; - struct resource *ioarea; - struct completion vsync; /* vsync irq event */ -}; - -static irqreturn_t sh7760fb_irq(int irq, void *data) -{ - struct completion *c = data; - - complete(c); - - return IRQ_HANDLED; -} - -/* wait_for_lps - wait until power supply has reached a certain state. */ -static int wait_for_lps(struct sh7760fb_par *par, int val) -{ - int i = 100; - while (--i && ((ioread16(par->base + LDPMMR) & 3) != val)) - msleep(1); - - if (i <= 0) - return -ETIMEDOUT; - - return 0; -} - -/* en/disable the LCDC */ -static int sh7760fb_blank(int blank, struct fb_info *info) -{ - struct sh7760fb_par *par = info->par; - struct sh7760fb_platdata *pd = par->pd; - unsigned short cntr = ioread16(par->base + LDCNTR); - unsigned short intr = ioread16(par->base + LDINTR); - int lps; - - if (blank == FB_BLANK_UNBLANK) { - intr |= VINT_START; - cntr = LDCNTR_DON2 | LDCNTR_DON; - lps = 3; - } else { - intr &= ~VINT_START; - cntr = LDCNTR_DON2; - lps = 0; - } - - if (pd->blank) - pd->blank(blank); - - iowrite16(intr, par->base + LDINTR); - iowrite16(cntr, par->base + LDCNTR); - - return wait_for_lps(par, lps); -} - -static int sh7760_setcolreg (u_int regno, - u_int red, u_int green, u_int blue, - u_int transp, struct fb_info *info) -{ - u32 *palette = info->pseudo_palette; - - if (regno >= 16) - return -EINVAL; - - /* only FB_VISUAL_TRUECOLOR supported */ - - red >>= 16 - info->var.red.length; - green >>= 16 - info->var.green.length; - blue >>= 16 - info->var.blue.length; - transp >>= 16 - info->var.transp.length; - - palette[regno] = (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset) | - (transp << info->var.transp.offset); - - return 0; -} - -static int sh7760fb_get_color_info(struct device *dev, - u16 lddfr, int *bpp, int *gray) -{ - int lbpp, lgray; - - lgray = lbpp = 0; - - switch (lddfr & LDDFR_COLOR_MASK) { - case LDDFR_1BPP_MONO: - lgray = 1; - lbpp = 1; - break; - case LDDFR_2BPP_MONO: - lgray = 1; - lbpp = 2; - break; - case LDDFR_4BPP_MONO: - lgray = 1; - case LDDFR_4BPP: - lbpp = 4; - break; - case LDDFR_6BPP_MONO: - lgray = 1; - case LDDFR_8BPP: - lbpp = 8; - break; - case LDDFR_16BPP_RGB555: - case LDDFR_16BPP_RGB565: - lbpp = 16; - lgray = 0; - break; - default: - dev_dbg(dev, "unsupported LDDFR bit depth.\n"); - return -EINVAL; - } - - if (bpp) - *bpp = lbpp; - if (gray) - *gray = lgray; - - return 0; -} - -static int sh7760fb_check_var(struct fb_var_screeninfo *var, - struct fb_info *info) -{ - struct fb_fix_screeninfo *fix = &info->fix; - struct sh7760fb_par *par = info->par; - int ret, bpp; - - /* get color info from register value */ - ret = sh7760fb_get_color_info(info->dev, par->pd->lddfr, &bpp, NULL); - if (ret) - return ret; - - var->bits_per_pixel = bpp; - - if ((var->grayscale) && (var->bits_per_pixel == 1)) - fix->visual = FB_VISUAL_MONO10; - else if (var->bits_per_pixel >= 15) - fix->visual = FB_VISUAL_TRUECOLOR; - else - fix->visual = FB_VISUAL_PSEUDOCOLOR; - - /* TODO: add some more validation here */ - return 0; -} - -/* - * sh7760fb_set_par - set videomode. - * - * NOTE: The rotation, grayscale and DSTN codepaths are - * totally untested! - */ -static int sh7760fb_set_par(struct fb_info *info) -{ - struct sh7760fb_par *par = info->par; - struct fb_videomode *vm = par->pd->def_mode; - unsigned long sbase, dstn_off, ldsarl, stride; - unsigned short hsynp, hsynw, htcn, hdcn; - unsigned short vsynp, vsynw, vtln, vdln; - unsigned short lddfr, ldmtr; - int ret, bpp, gray; - - par->rot = par->pd->rotate; - - /* rotate only works with xres <= 320 */ - if (par->rot && (vm->xres > 320)) { - dev_dbg(info->dev, "rotation disabled due to display size\n"); - par->rot = 0; - } - - /* calculate LCDC reg vals from display parameters */ - hsynp = vm->right_margin + vm->xres; - hsynw = vm->hsync_len; - htcn = vm->left_margin + hsynp + hsynw; - hdcn = vm->xres; - vsynp = vm->lower_margin + vm->yres; - vsynw = vm->vsync_len; - vtln = vm->upper_margin + vsynp + vsynw; - vdln = vm->yres; - - /* get color info from register value */ - ret = sh7760fb_get_color_info(info->dev, par->pd->lddfr, &bpp, &gray); - if (ret) - return ret; - - dev_dbg(info->dev, "%dx%d %dbpp %s (orientation %s)\n", hdcn, - vdln, bpp, gray ? "grayscale" : "color", - par->rot ? "rotated" : "normal"); - -#ifdef CONFIG_CPU_LITTLE_ENDIAN - lddfr = par->pd->lddfr | (1 << 8); -#else - lddfr = par->pd->lddfr & ~(1 << 8); -#endif - - ldmtr = par->pd->ldmtr; - - if (!(vm->sync & FB_SYNC_HOR_HIGH_ACT)) - ldmtr |= LDMTR_CL1POL; - if (!(vm->sync & FB_SYNC_VERT_HIGH_ACT)) - ldmtr |= LDMTR_FLMPOL; - - /* shut down LCDC before changing display parameters */ - sh7760fb_blank(FB_BLANK_POWERDOWN, info); - - iowrite16(par->pd->ldickr, par->base + LDICKR); /* pixclock */ - iowrite16(ldmtr, par->base + LDMTR); /* polarities */ - iowrite16(lddfr, par->base + LDDFR); /* color/depth */ - iowrite16((par->rot ? 1 << 13 : 0), par->base + LDSMR); /* rotate */ - iowrite16(par->pd->ldpmmr, par->base + LDPMMR); /* Power Management */ - iowrite16(par->pd->ldpspr, par->base + LDPSPR); /* Power Supply Ctrl */ - - /* display resolution */ - iowrite16(((htcn >> 3) - 1) | (((hdcn >> 3) - 1) << 8), - par->base + LDHCNR); - iowrite16(vdln - 1, par->base + LDVDLNR); - iowrite16(vtln - 1, par->base + LDVTLNR); - /* h/v sync signals */ - iowrite16((vsynp - 1) | ((vsynw - 1) << 12), par->base + LDVSYNR); - iowrite16(((hsynp >> 3) - 1) | (((hsynw >> 3) - 1) << 12), - par->base + LDHSYNR); - /* AC modulation sig */ - iowrite16(par->pd->ldaclnr, par->base + LDACLNR); - - stride = (par->rot) ? vtln : hdcn; - if (!gray) - stride *= (bpp + 7) >> 3; - else { - if (bpp == 1) - stride >>= 3; - else if (bpp == 2) - stride >>= 2; - else if (bpp == 4) - stride >>= 1; - /* 6 bpp == 8 bpp */ - } - - /* if rotated, stride must be power of 2 */ - if (par->rot) { - unsigned long bit = 1 << 31; - while (bit) { - if (stride & bit) - break; - bit >>= 1; - } - if (stride & ~bit) - stride = bit << 1; /* not P-o-2, round up */ - } - iowrite16(stride, par->base + LDLAOR); - - /* set display mem start address */ - sbase = (unsigned long)par->fbdma; - if (par->rot) - sbase += (hdcn - 1) * stride; - - iowrite32(sbase, par->base + LDSARU); - - /* - * for DSTN need to set address for lower half. - * I (mlau) don't know which address to set it to, - * so I guessed at (stride * yres/2). - */ - if (((ldmtr & 0x003f) >= LDMTR_DSTN_MONO_8) && - ((ldmtr & 0x003f) <= LDMTR_DSTN_COLOR_16)) { - - dev_dbg(info->dev, " ***** DSTN untested! *****\n"); - - dstn_off = stride; - if (par->rot) - dstn_off *= hdcn >> 1; - else - dstn_off *= vdln >> 1; - - ldsarl = sbase + dstn_off; - } else - ldsarl = 0; - - iowrite32(ldsarl, par->base + LDSARL); /* mem for lower half of DSTN */ - - info->fix.line_length = stride; - - sh7760fb_check_var(&info->var, info); - - sh7760fb_blank(FB_BLANK_UNBLANK, info); /* panel on! */ - - dev_dbg(info->dev, "hdcn : %6d htcn : %6d\n", hdcn, htcn); - dev_dbg(info->dev, "hsynw : %6d hsynp : %6d\n", hsynw, hsynp); - dev_dbg(info->dev, "vdln : %6d vtln : %6d\n", vdln, vtln); - dev_dbg(info->dev, "vsynw : %6d vsynp : %6d\n", vsynw, vsynp); - dev_dbg(info->dev, "clksrc: %6d clkdiv: %6d\n", - (par->pd->ldickr >> 12) & 3, par->pd->ldickr & 0x1f); - dev_dbg(info->dev, "ldpmmr: 0x%04x ldpspr: 0x%04x\n", par->pd->ldpmmr, - par->pd->ldpspr); - dev_dbg(info->dev, "ldmtr : 0x%04x lddfr : 0x%04x\n", ldmtr, lddfr); - dev_dbg(info->dev, "ldlaor: %ld\n", stride); - dev_dbg(info->dev, "ldsaru: 0x%08lx ldsarl: 0x%08lx\n", sbase, ldsarl); - - return 0; -} - -static const struct fb_ops sh7760fb_ops = { - .owner = THIS_MODULE, - .fb_blank = sh7760fb_blank, - .fb_check_var = sh7760fb_check_var, - .fb_setcolreg = sh7760_setcolreg, - .fb_set_par = sh7760fb_set_par, - .fb_fillrect = cfb_fillrect, - .fb_copyarea = cfb_copyarea, - .fb_imageblit = cfb_imageblit, -}; - -static void sh7760fb_free_mem(struct fb_info *info) -{ - struct sh7760fb_par *par = info->par; - - if (!info->screen_base) - return; - - dma_free_coherent(info->dev, info->screen_size, - info->screen_base, par->fbdma); - - par->fbdma = 0; - info->screen_base = NULL; - info->screen_size = 0; -} - -/* allocate the framebuffer memory. This memory must be in Area3, - * (dictated by the DMA engine) and contiguous, at a 512 byte boundary. - */ -static int sh7760fb_alloc_mem(struct fb_info *info) -{ - struct sh7760fb_par *par = info->par; - void *fbmem; - unsigned long vram; - int ret, bpp; - - if (info->screen_base) - return 0; - - /* get color info from register value */ - ret = sh7760fb_get_color_info(info->dev, par->pd->lddfr, &bpp, NULL); - if (ret) { - printk(KERN_ERR "colinfo\n"); - return ret; - } - - /* min VRAM: xres_min = 16, yres_min = 1, bpp = 1: 2byte -> 1 page - max VRAM: xres_max = 1024, yres_max = 1024, bpp = 16: 2MB */ - - vram = info->var.xres * info->var.yres; - if (info->var.grayscale) { - if (bpp == 1) - vram >>= 3; - else if (bpp == 2) - vram >>= 2; - else if (bpp == 4) - vram >>= 1; - } else if (bpp > 8) - vram *= 2; - if ((vram < 1) || (vram > 1024 * 2048)) { - dev_dbg(info->dev, "too much VRAM required. Check settings\n"); - return -ENODEV; - } - - if (vram < PAGE_SIZE) - vram = PAGE_SIZE; - - fbmem = dma_alloc_coherent(info->dev, vram, &par->fbdma, GFP_KERNEL); - - if (!fbmem) - return -ENOMEM; - - if ((par->fbdma & SH7760FB_DMA_MASK) != SH7760FB_DMA_MASK) { - sh7760fb_free_mem(info); - dev_err(info->dev, "kernel gave me memory at 0x%08lx, which is" - "unusable for the LCDC\n", (unsigned long)par->fbdma); - return -ENOMEM; - } - - info->screen_base = fbmem; - info->screen_size = vram; - info->fix.smem_start = (unsigned long)info->screen_base; - info->fix.smem_len = info->screen_size; - - return 0; -} - -static int sh7760fb_probe(struct platform_device *pdev) -{ - struct fb_info *info; - struct resource *res; - struct sh7760fb_par *par; - int ret; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (unlikely(res == NULL)) { - dev_err(&pdev->dev, "invalid resource\n"); - return -EINVAL; - } - - info = framebuffer_alloc(sizeof(struct sh7760fb_par), &pdev->dev); - if (!info) - return -ENOMEM; - - par = info->par; - par->dev = pdev; - - par->pd = pdev->dev.platform_data; - if (!par->pd) { - dev_dbg(info->dev, "no display setup data!\n"); - ret = -ENODEV; - goto out_fb; - } - - par->ioarea = request_mem_region(res->start, - resource_size(res), pdev->name); - if (!par->ioarea) { - dev_err(&pdev->dev, "mmio area busy\n"); - ret = -EBUSY; - goto out_fb; - } - - par->base = ioremap(res->start, resource_size(res)); - if (!par->base) { - dev_err(&pdev->dev, "cannot remap\n"); - ret = -ENODEV; - goto out_res; - } - - iowrite16(0, par->base + LDINTR); /* disable vsync irq */ - par->irq = platform_get_irq(pdev, 0); - if (par->irq >= 0) { - ret = request_irq(par->irq, sh7760fb_irq, 0, - "sh7760-lcdc", &par->vsync); - if (ret) { - dev_err(&pdev->dev, "cannot grab IRQ\n"); - par->irq = -ENXIO; - } else - disable_irq_nosync(par->irq); - } - - fb_videomode_to_var(&info->var, par->pd->def_mode); - - ret = sh7760fb_alloc_mem(info); - if (ret) { - dev_dbg(info->dev, "framebuffer memory allocation failed!\n"); - goto out_unmap; - } - - info->pseudo_palette = par->pseudo_palette; - - /* fixup color register bitpositions. These are fixed by hardware */ - info->var.red.offset = 11; - info->var.red.length = 5; - info->var.red.msb_right = 0; - - info->var.green.offset = 5; - info->var.green.length = 6; - info->var.green.msb_right = 0; - - info->var.blue.offset = 0; - info->var.blue.length = 5; - info->var.blue.msb_right = 0; - - info->var.transp.offset = 0; - info->var.transp.length = 0; - info->var.transp.msb_right = 0; - - strcpy(info->fix.id, "sh7760-lcdc"); - - /* set the DON2 bit now, before cmap allocation, as it will randomize - * palette memory. - */ - iowrite16(LDCNTR_DON2, par->base + LDCNTR); - info->fbops = &sh7760fb_ops; - - ret = fb_alloc_cmap(&info->cmap, 256, 0); - if (ret) { - dev_dbg(info->dev, "Unable to allocate cmap memory\n"); - goto out_mem; - } - - ret = register_framebuffer(info); - if (ret < 0) { - dev_dbg(info->dev, "cannot register fb!\n"); - goto out_cmap; - } - platform_set_drvdata(pdev, info); - - printk(KERN_INFO "%s: memory at phys 0x%08lx-0x%08lx, size %ld KiB\n", - pdev->name, - (unsigned long)par->fbdma, - (unsigned long)(par->fbdma + info->screen_size - 1), - info->screen_size >> 10); - - return 0; - -out_cmap: - sh7760fb_blank(FB_BLANK_POWERDOWN, info); - fb_dealloc_cmap(&info->cmap); -out_mem: - sh7760fb_free_mem(info); -out_unmap: - if (par->irq >= 0) - free_irq(par->irq, &par->vsync); - iounmap(par->base); -out_res: - release_mem_region(res->start, resource_size(res)); -out_fb: - framebuffer_release(info); - return ret; -} - -static int sh7760fb_remove(struct platform_device *dev) -{ - struct fb_info *info = platform_get_drvdata(dev); - struct sh7760fb_par *par = info->par; - - sh7760fb_blank(FB_BLANK_POWERDOWN, info); - unregister_framebuffer(info); - fb_dealloc_cmap(&info->cmap); - sh7760fb_free_mem(info); - if (par->irq >= 0) - free_irq(par->irq, &par->vsync); - iounmap(par->base); - release_mem_region(par->ioarea->start, resource_size(par->ioarea)); - framebuffer_release(info); - - return 0; -} - -static struct platform_driver sh7760_lcdc_driver = { - .driver = { - .name = "sh7760-lcdc", - }, - .probe = sh7760fb_probe, - .remove = sh7760fb_remove, -}; - -module_platform_driver(sh7760_lcdc_driver); - -MODULE_AUTHOR("Nobuhiro Iwamatsu, Manuel Lauss"); -MODULE_DESCRIPTION("FBdev for SH7760/63 integrated LCD Controller"); -MODULE_LICENSE("GPL v2"); From patchwork Fri Jan 13 06:23:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644793 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F48AC678DB for ; Fri, 13 Jan 2023 06:30:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241343AbjAMGaP (ORCPT ); Fri, 13 Jan 2023 01:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235576AbjAMG1H (ORCPT ); Fri, 13 Jan 2023 01:27:07 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 505765C1CD; Thu, 12 Jan 2023 22:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mVSad5lHjsb+kxcSGYOjz7Q3t7OZ/7w3LWvLI7wl90c=; b=dTK4NKZNZ24B+Iy3vetLl8In0m 6QyXKjhgkJrMmLcUyhOZKbm0vIupFnylr7pYV8S2hu8IL5FEJ97IN1LaPho1YjqLe7sI4/ONQJffd HrN4knY96XfBH5Dg16XcB4D80tb+duR4+tun9eS3VUi93MmJDYYqXUhNRhigBMvcX6O86ZVpgYnP0 Oxo0qqd0c7Q9G2IGb9v1zvuuBflZwymgNPjOxWZjze2G/7PRQRiTyI0cvMRK8B8AtZNO1IocwGSOj LywcuT2MFfxcH/2VNQ6voqoVr4Z3t4S8OtiyGNcDIfWd6cbKEA49ubHxa8fQ7cQSeujuP6MMQBLYI oC2zjRYw==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDUi-000m58-BO; Fri, 13 Jan 2023 06:24:53 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 20/22] media: remove sh_vou Date: Fri, 13 Jan 2023 07:23:37 +0100 Message-Id: <20230113062339.1909087-21-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Now that arch/sh is removed this driver is dead code. Signed-off-by: Christoph Hellwig --- drivers/media/platform/renesas/Kconfig | 9 - drivers/media/platform/renesas/Makefile | 1 - drivers/media/platform/renesas/sh_vou.c | 1375 ----------------------- 3 files changed, 1385 deletions(-) delete mode 100644 drivers/media/platform/renesas/sh_vou.c diff --git a/drivers/media/platform/renesas/Kconfig b/drivers/media/platform/renesas/Kconfig index 0231672a7e1c32..935b24b864380e 100644 --- a/drivers/media/platform/renesas/Kconfig +++ b/drivers/media/platform/renesas/Kconfig @@ -31,15 +31,6 @@ config VIDEO_RCAR_ISP To compile this driver as a module, choose M here: the module will be called rcar-isp. -config VIDEO_SH_VOU - tristate "SuperH VOU video output driver" - depends on V4L_PLATFORM_DRIVERS - depends on VIDEO_DEV && I2C - depends on ARCH_SHMOBILE || COMPILE_TEST - select VIDEOBUF2_DMA_CONTIG - help - Support for the Video Output Unit (VOU) on SuperH SoCs. - source "drivers/media/platform/renesas/rcar-vin/Kconfig" source "drivers/media/platform/renesas/rzg2l-cru/Kconfig" diff --git a/drivers/media/platform/renesas/Makefile b/drivers/media/platform/renesas/Makefile index 55854e8688870f..1ae7d825073df3 100644 --- a/drivers/media/platform/renesas/Makefile +++ b/drivers/media/platform/renesas/Makefile @@ -13,4 +13,3 @@ obj-$(CONFIG_VIDEO_RENESAS_CEU) += renesas-ceu.o obj-$(CONFIG_VIDEO_RENESAS_FCP) += rcar-fcp.o obj-$(CONFIG_VIDEO_RENESAS_FDP1) += rcar_fdp1.o obj-$(CONFIG_VIDEO_RENESAS_JPU) += rcar_jpu.o -obj-$(CONFIG_VIDEO_SH_VOU) += sh_vou.o diff --git a/drivers/media/platform/renesas/sh_vou.c b/drivers/media/platform/renesas/sh_vou.c deleted file mode 100644 index ca4310e26c49ee..00000000000000 --- a/drivers/media/platform/renesas/sh_vou.c +++ /dev/null @@ -1,1375 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * SuperH Video Output Unit (VOU) driver - * - * Copyright (C) 2010, Guennadi Liakhovetski - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -/* Mirror addresses are not available for all registers */ -#define VOUER 0 -#define VOUCR 4 -#define VOUSTR 8 -#define VOUVCR 0xc -#define VOUISR 0x10 -#define VOUBCR 0x14 -#define VOUDPR 0x18 -#define VOUDSR 0x1c -#define VOUVPR 0x20 -#define VOUIR 0x24 -#define VOUSRR 0x28 -#define VOUMSR 0x2c -#define VOUHIR 0x30 -#define VOUDFR 0x34 -#define VOUAD1R 0x38 -#define VOUAD2R 0x3c -#define VOUAIR 0x40 -#define VOUSWR 0x44 -#define VOURCR 0x48 -#define VOURPR 0x50 - -enum sh_vou_status { - SH_VOU_IDLE, - SH_VOU_INITIALISING, - SH_VOU_RUNNING, -}; - -#define VOU_MIN_IMAGE_WIDTH 16 -#define VOU_MAX_IMAGE_WIDTH 720 -#define VOU_MIN_IMAGE_HEIGHT 16 - -struct sh_vou_buffer { - struct vb2_v4l2_buffer vb; - struct list_head list; -}; - -static inline struct -sh_vou_buffer *to_sh_vou_buffer(struct vb2_v4l2_buffer *vb2) -{ - return container_of(vb2, struct sh_vou_buffer, vb); -} - -struct sh_vou_device { - struct v4l2_device v4l2_dev; - struct video_device vdev; - struct sh_vou_pdata *pdata; - spinlock_t lock; - void __iomem *base; - /* State information */ - struct v4l2_pix_format pix; - struct v4l2_rect rect; - struct list_head buf_list; - v4l2_std_id std; - int pix_idx; - struct vb2_queue queue; - struct sh_vou_buffer *active; - enum sh_vou_status status; - unsigned sequence; - struct mutex fop_lock; -}; - -/* Register access routines for sides A, B and mirror addresses */ -static void sh_vou_reg_a_write(struct sh_vou_device *vou_dev, unsigned int reg, - u32 value) -{ - __raw_writel(value, vou_dev->base + reg); -} - -static void sh_vou_reg_ab_write(struct sh_vou_device *vou_dev, unsigned int reg, - u32 value) -{ - __raw_writel(value, vou_dev->base + reg); - __raw_writel(value, vou_dev->base + reg + 0x1000); -} - -static void sh_vou_reg_m_write(struct sh_vou_device *vou_dev, unsigned int reg, - u32 value) -{ - __raw_writel(value, vou_dev->base + reg + 0x2000); -} - -static u32 sh_vou_reg_a_read(struct sh_vou_device *vou_dev, unsigned int reg) -{ - return __raw_readl(vou_dev->base + reg); -} - -static void sh_vou_reg_a_set(struct sh_vou_device *vou_dev, unsigned int reg, - u32 value, u32 mask) -{ - u32 old = __raw_readl(vou_dev->base + reg); - - value = (value & mask) | (old & ~mask); - __raw_writel(value, vou_dev->base + reg); -} - -static void sh_vou_reg_b_set(struct sh_vou_device *vou_dev, unsigned int reg, - u32 value, u32 mask) -{ - sh_vou_reg_a_set(vou_dev, reg + 0x1000, value, mask); -} - -static void sh_vou_reg_ab_set(struct sh_vou_device *vou_dev, unsigned int reg, - u32 value, u32 mask) -{ - sh_vou_reg_a_set(vou_dev, reg, value, mask); - sh_vou_reg_b_set(vou_dev, reg, value, mask); -} - -struct sh_vou_fmt { - u32 pfmt; - unsigned char bpp; - unsigned char bpl; - unsigned char rgb; - unsigned char yf; - unsigned char pkf; -}; - -/* Further pixel formats can be added */ -static struct sh_vou_fmt vou_fmt[] = { - { - .pfmt = V4L2_PIX_FMT_NV12, - .bpp = 12, - .bpl = 1, - .yf = 0, - .rgb = 0, - }, - { - .pfmt = V4L2_PIX_FMT_NV16, - .bpp = 16, - .bpl = 1, - .yf = 1, - .rgb = 0, - }, - { - .pfmt = V4L2_PIX_FMT_RGB24, - .bpp = 24, - .bpl = 3, - .pkf = 2, - .rgb = 1, - }, - { - .pfmt = V4L2_PIX_FMT_RGB565, - .bpp = 16, - .bpl = 2, - .pkf = 3, - .rgb = 1, - }, - { - .pfmt = V4L2_PIX_FMT_RGB565X, - .bpp = 16, - .bpl = 2, - .pkf = 3, - .rgb = 1, - }, -}; - -static void sh_vou_schedule_next(struct sh_vou_device *vou_dev, - struct vb2_v4l2_buffer *vbuf) -{ - dma_addr_t addr1, addr2; - - addr1 = vb2_dma_contig_plane_dma_addr(&vbuf->vb2_buf, 0); - switch (vou_dev->pix.pixelformat) { - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV16: - addr2 = addr1 + vou_dev->pix.width * vou_dev->pix.height; - break; - default: - addr2 = 0; - } - - sh_vou_reg_m_write(vou_dev, VOUAD1R, addr1); - sh_vou_reg_m_write(vou_dev, VOUAD2R, addr2); -} - -static void sh_vou_stream_config(struct sh_vou_device *vou_dev) -{ - unsigned int row_coeff; -#ifdef __LITTLE_ENDIAN - u32 dataswap = 7; -#else - u32 dataswap = 0; -#endif - - switch (vou_dev->pix.pixelformat) { - default: - case V4L2_PIX_FMT_NV12: - case V4L2_PIX_FMT_NV16: - row_coeff = 1; - break; - case V4L2_PIX_FMT_RGB565: - dataswap ^= 1; - fallthrough; - case V4L2_PIX_FMT_RGB565X: - row_coeff = 2; - break; - case V4L2_PIX_FMT_RGB24: - row_coeff = 3; - break; - } - - sh_vou_reg_a_write(vou_dev, VOUSWR, dataswap); - sh_vou_reg_ab_write(vou_dev, VOUAIR, vou_dev->pix.width * row_coeff); -} - -/* Locking: caller holds fop_lock mutex */ -static int sh_vou_queue_setup(struct vb2_queue *vq, - unsigned int *nbuffers, unsigned int *nplanes, - unsigned int sizes[], struct device *alloc_devs[]) -{ - struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq); - struct v4l2_pix_format *pix = &vou_dev->pix; - int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - if (*nplanes) - return sizes[0] < pix->height * bytes_per_line ? -EINVAL : 0; - *nplanes = 1; - sizes[0] = pix->height * bytes_per_line; - return 0; -} - -static int sh_vou_buf_prepare(struct vb2_buffer *vb) -{ - struct sh_vou_device *vou_dev = vb2_get_drv_priv(vb->vb2_queue); - struct v4l2_pix_format *pix = &vou_dev->pix; - unsigned bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8; - unsigned size = pix->height * bytes_per_line; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - if (vb2_plane_size(vb, 0) < size) { - /* User buffer too small */ - dev_warn(vou_dev->v4l2_dev.dev, "buffer too small (%lu < %u)\n", - vb2_plane_size(vb, 0), size); - return -EINVAL; - } - - vb2_set_plane_payload(vb, 0, size); - return 0; -} - -/* Locking: caller holds fop_lock mutex and vq->irqlock spinlock */ -static void sh_vou_buf_queue(struct vb2_buffer *vb) -{ - struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); - struct sh_vou_device *vou_dev = vb2_get_drv_priv(vb->vb2_queue); - struct sh_vou_buffer *shbuf = to_sh_vou_buffer(vbuf); - unsigned long flags; - - spin_lock_irqsave(&vou_dev->lock, flags); - list_add_tail(&shbuf->list, &vou_dev->buf_list); - spin_unlock_irqrestore(&vou_dev->lock, flags); -} - -static int sh_vou_start_streaming(struct vb2_queue *vq, unsigned int count) -{ - struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq); - struct sh_vou_buffer *buf, *node; - int ret; - - vou_dev->sequence = 0; - ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, - video, s_stream, 1); - if (ret < 0 && ret != -ENOIOCTLCMD) { - list_for_each_entry_safe(buf, node, &vou_dev->buf_list, list) { - vb2_buffer_done(&buf->vb.vb2_buf, - VB2_BUF_STATE_QUEUED); - list_del(&buf->list); - } - vou_dev->active = NULL; - return ret; - } - - buf = list_entry(vou_dev->buf_list.next, struct sh_vou_buffer, list); - - vou_dev->active = buf; - - /* Start from side A: we use mirror addresses, so, set B */ - sh_vou_reg_a_write(vou_dev, VOURPR, 1); - dev_dbg(vou_dev->v4l2_dev.dev, "%s: first buffer status 0x%x\n", - __func__, sh_vou_reg_a_read(vou_dev, VOUSTR)); - sh_vou_schedule_next(vou_dev, &buf->vb); - - buf = list_entry(buf->list.next, struct sh_vou_buffer, list); - - /* Second buffer - initialise register side B */ - sh_vou_reg_a_write(vou_dev, VOURPR, 0); - sh_vou_schedule_next(vou_dev, &buf->vb); - - /* Register side switching with frame VSYNC */ - sh_vou_reg_a_write(vou_dev, VOURCR, 5); - - sh_vou_stream_config(vou_dev); - /* Enable End-of-Frame (VSYNC) interrupts */ - sh_vou_reg_a_write(vou_dev, VOUIR, 0x10004); - - /* Two buffers on the queue - activate the hardware */ - vou_dev->status = SH_VOU_RUNNING; - sh_vou_reg_a_write(vou_dev, VOUER, 0x107); - return 0; -} - -static void sh_vou_stop_streaming(struct vb2_queue *vq) -{ - struct sh_vou_device *vou_dev = vb2_get_drv_priv(vq); - struct sh_vou_buffer *buf, *node; - unsigned long flags; - - v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, - video, s_stream, 0); - /* disable output */ - sh_vou_reg_a_set(vou_dev, VOUER, 0, 1); - /* ...but the current frame will complete */ - sh_vou_reg_a_set(vou_dev, VOUIR, 0, 0x30000); - msleep(50); - spin_lock_irqsave(&vou_dev->lock, flags); - list_for_each_entry_safe(buf, node, &vou_dev->buf_list, list) { - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - list_del(&buf->list); - } - vou_dev->active = NULL; - spin_unlock_irqrestore(&vou_dev->lock, flags); -} - -static const struct vb2_ops sh_vou_qops = { - .queue_setup = sh_vou_queue_setup, - .buf_prepare = sh_vou_buf_prepare, - .buf_queue = sh_vou_buf_queue, - .start_streaming = sh_vou_start_streaming, - .stop_streaming = sh_vou_stop_streaming, - .wait_prepare = vb2_ops_wait_prepare, - .wait_finish = vb2_ops_wait_finish, -}; - -/* Video IOCTLs */ -static int sh_vou_querycap(struct file *file, void *priv, - struct v4l2_capability *cap) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - strscpy(cap->card, "SuperH VOU", sizeof(cap->card)); - strscpy(cap->driver, "sh-vou", sizeof(cap->driver)); - strscpy(cap->bus_info, "platform:sh-vou", sizeof(cap->bus_info)); - return 0; -} - -/* Enumerate formats, that the device can accept from the user */ -static int sh_vou_enum_fmt_vid_out(struct file *file, void *priv, - struct v4l2_fmtdesc *fmt) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - if (fmt->index >= ARRAY_SIZE(vou_fmt)) - return -EINVAL; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - fmt->pixelformat = vou_fmt[fmt->index].pfmt; - - return 0; -} - -static int sh_vou_g_fmt_vid_out(struct file *file, void *priv, - struct v4l2_format *fmt) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - fmt->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - fmt->fmt.pix = vou_dev->pix; - - return 0; -} - -static const unsigned char vou_scale_h_num[] = {1, 9, 2, 9, 4}; -static const unsigned char vou_scale_h_den[] = {1, 8, 1, 4, 1}; -static const unsigned char vou_scale_h_fld[] = {0, 2, 1, 3}; -static const unsigned char vou_scale_v_num[] = {1, 2, 4}; -static const unsigned char vou_scale_v_den[] = {1, 1, 1}; -static const unsigned char vou_scale_v_fld[] = {0, 1}; - -static void sh_vou_configure_geometry(struct sh_vou_device *vou_dev, - int pix_idx, int w_idx, int h_idx) -{ - struct sh_vou_fmt *fmt = vou_fmt + pix_idx; - unsigned int black_left, black_top, width_max, - frame_in_height, frame_out_height, frame_out_top; - struct v4l2_rect *rect = &vou_dev->rect; - struct v4l2_pix_format *pix = &vou_dev->pix; - u32 vouvcr = 0, dsr_h, dsr_v; - - if (vou_dev->std & V4L2_STD_525_60) { - width_max = 858; - /* height_max = 262; */ - } else { - width_max = 864; - /* height_max = 312; */ - } - - frame_in_height = pix->height / 2; - frame_out_height = rect->height / 2; - frame_out_top = rect->top / 2; - - /* - * Cropping scheme: max useful image is 720x480, and the total video - * area is 858x525 (NTSC) or 864x625 (PAL). AK8813 / 8814 starts - * sampling data beginning with fixed 276th (NTSC) / 288th (PAL) clock, - * of which the first 33 / 25 clocks HSYNC must be held active. This - * has to be configured in CR[HW]. 1 pixel equals 2 clock periods. - * This gives CR[HW] = 16 / 12, VPR[HVP] = 138 / 144, which gives - * exactly 858 - 138 = 864 - 144 = 720! We call the out-of-display area, - * beyond DSR, specified on the left and top by the VPR register "black - * pixels" and out-of-image area (DPR) "background pixels." We fix VPR - * at 138 / 144 : 20, because that's the HSYNC timing, that our first - * client requires, and that's exactly what leaves us 720 pixels for the - * image; we leave VPR[VVP] at default 20 for now, because the client - * doesn't seem to have any special requirements for it. Otherwise we - * could also set it to max - 240 = 22 / 72. Thus VPR depends only on - * the selected standard, and DPR and DSR are selected according to - * cropping. Q: how does the client detect the first valid line? Does - * HSYNC stay inactive during invalid (black) lines? - */ - black_left = width_max - VOU_MAX_IMAGE_WIDTH; - black_top = 20; - - dsr_h = rect->width + rect->left; - dsr_v = frame_out_height + frame_out_top; - - dev_dbg(vou_dev->v4l2_dev.dev, - "image %ux%u, black %u:%u, offset %u:%u, display %ux%u\n", - pix->width, frame_in_height, black_left, black_top, - rect->left, frame_out_top, dsr_h, dsr_v); - - /* VOUISR height - half of a frame height in frame mode */ - sh_vou_reg_ab_write(vou_dev, VOUISR, (pix->width << 16) | frame_in_height); - sh_vou_reg_ab_write(vou_dev, VOUVPR, (black_left << 16) | black_top); - sh_vou_reg_ab_write(vou_dev, VOUDPR, (rect->left << 16) | frame_out_top); - sh_vou_reg_ab_write(vou_dev, VOUDSR, (dsr_h << 16) | dsr_v); - - /* - * if necessary, we could set VOUHIR to - * max(black_left + dsr_h, width_max) here - */ - - if (w_idx) - vouvcr |= (1 << 15) | (vou_scale_h_fld[w_idx - 1] << 4); - if (h_idx) - vouvcr |= (1 << 14) | vou_scale_v_fld[h_idx - 1]; - - dev_dbg(vou_dev->v4l2_dev.dev, "0x%08x: scaling 0x%x\n", - fmt->pfmt, vouvcr); - - /* To produce a colour bar for testing set bit 23 of VOUVCR */ - sh_vou_reg_ab_write(vou_dev, VOUVCR, vouvcr); - sh_vou_reg_ab_write(vou_dev, VOUDFR, - fmt->pkf | (fmt->yf << 8) | (fmt->rgb << 16)); -} - -struct sh_vou_geometry { - struct v4l2_rect output; - unsigned int in_width; - unsigned int in_height; - int scale_idx_h; - int scale_idx_v; -}; - -/* - * Find input geometry, that we can use to produce output, closest to the - * requested rectangle, using VOU scaling - */ -static void vou_adjust_input(struct sh_vou_geometry *geo, v4l2_std_id std) -{ - /* The compiler cannot know, that best and idx will indeed be set */ - unsigned int best_err = UINT_MAX, best = 0, img_height_max; - int i, idx = 0; - - if (std & V4L2_STD_525_60) - img_height_max = 480; - else - img_height_max = 576; - - /* Image width must be a multiple of 4 */ - v4l_bound_align_image(&geo->in_width, - VOU_MIN_IMAGE_WIDTH, VOU_MAX_IMAGE_WIDTH, 2, - &geo->in_height, - VOU_MIN_IMAGE_HEIGHT, img_height_max, 1, 0); - - /* Select scales to come as close as possible to the output image */ - for (i = ARRAY_SIZE(vou_scale_h_num) - 1; i >= 0; i--) { - unsigned int err; - unsigned int found = geo->output.width * vou_scale_h_den[i] / - vou_scale_h_num[i]; - - if (found > VOU_MAX_IMAGE_WIDTH) - /* scales increase */ - break; - - err = abs(found - geo->in_width); - if (err < best_err) { - best_err = err; - idx = i; - best = found; - } - if (!err) - break; - } - - geo->in_width = best; - geo->scale_idx_h = idx; - - best_err = UINT_MAX; - - /* This loop can be replaced with one division */ - for (i = ARRAY_SIZE(vou_scale_v_num) - 1; i >= 0; i--) { - unsigned int err; - unsigned int found = geo->output.height * vou_scale_v_den[i] / - vou_scale_v_num[i]; - - if (found > img_height_max) - /* scales increase */ - break; - - err = abs(found - geo->in_height); - if (err < best_err) { - best_err = err; - idx = i; - best = found; - } - if (!err) - break; - } - - geo->in_height = best; - geo->scale_idx_v = idx; -} - -/* - * Find output geometry, that we can produce, using VOU scaling, closest to - * the requested rectangle - */ -static void vou_adjust_output(struct sh_vou_geometry *geo, v4l2_std_id std) -{ - unsigned int best_err = UINT_MAX, best = geo->in_width, - width_max, height_max, img_height_max; - int i, idx_h = 0, idx_v = 0; - - if (std & V4L2_STD_525_60) { - width_max = 858; - height_max = 262 * 2; - img_height_max = 480; - } else { - width_max = 864; - height_max = 312 * 2; - img_height_max = 576; - } - - /* Select scales to come as close as possible to the output image */ - for (i = 0; i < ARRAY_SIZE(vou_scale_h_num); i++) { - unsigned int err; - unsigned int found = geo->in_width * vou_scale_h_num[i] / - vou_scale_h_den[i]; - - if (found > VOU_MAX_IMAGE_WIDTH) - /* scales increase */ - break; - - err = abs(found - geo->output.width); - if (err < best_err) { - best_err = err; - idx_h = i; - best = found; - } - if (!err) - break; - } - - geo->output.width = best; - geo->scale_idx_h = idx_h; - if (geo->output.left + best > width_max) - geo->output.left = width_max - best; - - pr_debug("%s(): W %u * %u/%u = %u\n", __func__, geo->in_width, - vou_scale_h_num[idx_h], vou_scale_h_den[idx_h], best); - - best_err = UINT_MAX; - - /* This loop can be replaced with one division */ - for (i = 0; i < ARRAY_SIZE(vou_scale_v_num); i++) { - unsigned int err; - unsigned int found = geo->in_height * vou_scale_v_num[i] / - vou_scale_v_den[i]; - - if (found > img_height_max) - /* scales increase */ - break; - - err = abs(found - geo->output.height); - if (err < best_err) { - best_err = err; - idx_v = i; - best = found; - } - if (!err) - break; - } - - geo->output.height = best; - geo->scale_idx_v = idx_v; - if (geo->output.top + best > height_max) - geo->output.top = height_max - best; - - pr_debug("%s(): H %u * %u/%u = %u\n", __func__, geo->in_height, - vou_scale_v_num[idx_v], vou_scale_v_den[idx_v], best); -} - -static int sh_vou_try_fmt_vid_out(struct file *file, void *priv, - struct v4l2_format *fmt) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - struct v4l2_pix_format *pix = &fmt->fmt.pix; - unsigned int img_height_max; - int pix_idx; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - pix->field = V4L2_FIELD_INTERLACED; - pix->colorspace = V4L2_COLORSPACE_SMPTE170M; - pix->ycbcr_enc = pix->quantization = 0; - - for (pix_idx = 0; pix_idx < ARRAY_SIZE(vou_fmt); pix_idx++) - if (vou_fmt[pix_idx].pfmt == pix->pixelformat) - break; - - if (pix_idx == ARRAY_SIZE(vou_fmt)) - return -EINVAL; - - if (vou_dev->std & V4L2_STD_525_60) - img_height_max = 480; - else - img_height_max = 576; - - v4l_bound_align_image(&pix->width, - VOU_MIN_IMAGE_WIDTH, VOU_MAX_IMAGE_WIDTH, 2, - &pix->height, - VOU_MIN_IMAGE_HEIGHT, img_height_max, 1, 0); - pix->bytesperline = pix->width * vou_fmt[pix_idx].bpl; - pix->sizeimage = pix->height * ((pix->width * vou_fmt[pix_idx].bpp) >> 3); - - return 0; -} - -static int sh_vou_set_fmt_vid_out(struct sh_vou_device *vou_dev, - struct v4l2_pix_format *pix) -{ - unsigned int img_height_max; - struct sh_vou_geometry geo; - struct v4l2_subdev_format format = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - /* Revisit: is this the correct code? */ - .format.code = MEDIA_BUS_FMT_YUYV8_2X8, - .format.field = V4L2_FIELD_INTERLACED, - .format.colorspace = V4L2_COLORSPACE_SMPTE170M, - }; - struct v4l2_mbus_framefmt *mbfmt = &format.format; - int pix_idx; - int ret; - - if (vb2_is_busy(&vou_dev->queue)) - return -EBUSY; - - for (pix_idx = 0; pix_idx < ARRAY_SIZE(vou_fmt); pix_idx++) - if (vou_fmt[pix_idx].pfmt == pix->pixelformat) - break; - - geo.in_width = pix->width; - geo.in_height = pix->height; - geo.output = vou_dev->rect; - - vou_adjust_output(&geo, vou_dev->std); - - mbfmt->width = geo.output.width; - mbfmt->height = geo.output.height; - ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, pad, - set_fmt, NULL, &format); - /* Must be implemented, so, don't check for -ENOIOCTLCMD */ - if (ret < 0) - return ret; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__, - geo.output.width, geo.output.height, mbfmt->width, mbfmt->height); - - if (vou_dev->std & V4L2_STD_525_60) - img_height_max = 480; - else - img_height_max = 576; - - /* Sanity checks */ - if ((unsigned)mbfmt->width > VOU_MAX_IMAGE_WIDTH || - (unsigned)mbfmt->height > img_height_max || - mbfmt->code != MEDIA_BUS_FMT_YUYV8_2X8) - return -EIO; - - if (mbfmt->width != geo.output.width || - mbfmt->height != geo.output.height) { - geo.output.width = mbfmt->width; - geo.output.height = mbfmt->height; - - vou_adjust_input(&geo, vou_dev->std); - } - - /* We tried to preserve output rectangle, but it could have changed */ - vou_dev->rect = geo.output; - pix->width = geo.in_width; - pix->height = geo.in_height; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u\n", __func__, - pix->width, pix->height); - - vou_dev->pix_idx = pix_idx; - - vou_dev->pix = *pix; - - sh_vou_configure_geometry(vou_dev, pix_idx, - geo.scale_idx_h, geo.scale_idx_v); - - return 0; -} - -static int sh_vou_s_fmt_vid_out(struct file *file, void *priv, - struct v4l2_format *fmt) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - int ret = sh_vou_try_fmt_vid_out(file, priv, fmt); - - if (ret) - return ret; - return sh_vou_set_fmt_vid_out(vou_dev, &fmt->fmt.pix); -} - -static int sh_vou_enum_output(struct file *file, void *fh, - struct v4l2_output *a) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - if (a->index) - return -EINVAL; - strscpy(a->name, "Video Out", sizeof(a->name)); - a->type = V4L2_OUTPUT_TYPE_ANALOG; - a->std = vou_dev->vdev.tvnorms; - return 0; -} - -static int sh_vou_g_output(struct file *file, void *fh, unsigned int *i) -{ - *i = 0; - return 0; -} - -static int sh_vou_s_output(struct file *file, void *fh, unsigned int i) -{ - return i ? -EINVAL : 0; -} - -static u32 sh_vou_ntsc_mode(enum sh_vou_bus_fmt bus_fmt) -{ - switch (bus_fmt) { - default: - pr_warn("%s(): Invalid bus-format code %d, using default 8-bit\n", - __func__, bus_fmt); - fallthrough; - case SH_VOU_BUS_8BIT: - return 1; - case SH_VOU_BUS_16BIT: - return 0; - case SH_VOU_BUS_BT656: - return 3; - } -} - -static int sh_vou_s_std(struct file *file, void *priv, v4l2_std_id std_id) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - int ret; - - dev_dbg(vou_dev->v4l2_dev.dev, "%s(): 0x%llx\n", __func__, std_id); - - if (std_id == vou_dev->std) - return 0; - - if (vb2_is_busy(&vou_dev->queue)) - return -EBUSY; - - ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, - s_std_output, std_id); - /* Shall we continue, if the subdev doesn't support .s_std_output()? */ - if (ret < 0 && ret != -ENOIOCTLCMD) - return ret; - - vou_dev->rect.top = vou_dev->rect.left = 0; - vou_dev->rect.width = VOU_MAX_IMAGE_WIDTH; - if (std_id & V4L2_STD_525_60) { - sh_vou_reg_ab_set(vou_dev, VOUCR, - sh_vou_ntsc_mode(vou_dev->pdata->bus_fmt) << 29, 7 << 29); - vou_dev->rect.height = 480; - } else { - sh_vou_reg_ab_set(vou_dev, VOUCR, 5 << 29, 7 << 29); - vou_dev->rect.height = 576; - } - - vou_dev->pix.width = vou_dev->rect.width; - vou_dev->pix.height = vou_dev->rect.height; - vou_dev->pix.bytesperline = - vou_dev->pix.width * vou_fmt[vou_dev->pix_idx].bpl; - vou_dev->pix.sizeimage = vou_dev->pix.height * - ((vou_dev->pix.width * vou_fmt[vou_dev->pix_idx].bpp) >> 3); - vou_dev->std = std_id; - sh_vou_set_fmt_vid_out(vou_dev, &vou_dev->pix); - - return 0; -} - -static int sh_vou_g_std(struct file *file, void *priv, v4l2_std_id *std) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); - - *std = vou_dev->std; - - return 0; -} - -static int sh_vou_log_status(struct file *file, void *priv) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - pr_info("VOUER: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUER)); - pr_info("VOUCR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUCR)); - pr_info("VOUSTR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUSTR)); - pr_info("VOUVCR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUVCR)); - pr_info("VOUISR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUISR)); - pr_info("VOUBCR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUBCR)); - pr_info("VOUDPR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUDPR)); - pr_info("VOUDSR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUDSR)); - pr_info("VOUVPR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUVPR)); - pr_info("VOUIR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUIR)); - pr_info("VOUSRR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUSRR)); - pr_info("VOUMSR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUMSR)); - pr_info("VOUHIR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUHIR)); - pr_info("VOUDFR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUDFR)); - pr_info("VOUAD1R: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUAD1R)); - pr_info("VOUAD2R: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUAD2R)); - pr_info("VOUAIR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUAIR)); - pr_info("VOUSWR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOUSWR)); - pr_info("VOURCR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOURCR)); - pr_info("VOURPR: 0x%08x\n", sh_vou_reg_a_read(vou_dev, VOURPR)); - return 0; -} - -static int sh_vou_g_selection(struct file *file, void *fh, - struct v4l2_selection *sel) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - - if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) - return -EINVAL; - switch (sel->target) { - case V4L2_SEL_TGT_COMPOSE: - sel->r = vou_dev->rect; - break; - case V4L2_SEL_TGT_COMPOSE_DEFAULT: - case V4L2_SEL_TGT_COMPOSE_BOUNDS: - sel->r.left = 0; - sel->r.top = 0; - sel->r.width = VOU_MAX_IMAGE_WIDTH; - if (vou_dev->std & V4L2_STD_525_60) - sel->r.height = 480; - else - sel->r.height = 576; - break; - default: - return -EINVAL; - } - return 0; -} - -/* Assume a dull encoder, do all the work ourselves. */ -static int sh_vou_s_selection(struct file *file, void *fh, - struct v4l2_selection *sel) -{ - struct v4l2_rect *rect = &sel->r; - struct sh_vou_device *vou_dev = video_drvdata(file); - struct v4l2_subdev_selection sd_sel = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - .target = V4L2_SEL_TGT_COMPOSE, - }; - struct v4l2_pix_format *pix = &vou_dev->pix; - struct sh_vou_geometry geo; - struct v4l2_subdev_format format = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - /* Revisit: is this the correct code? */ - .format.code = MEDIA_BUS_FMT_YUYV8_2X8, - .format.field = V4L2_FIELD_INTERLACED, - .format.colorspace = V4L2_COLORSPACE_SMPTE170M, - }; - unsigned int img_height_max; - int ret; - - if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT || - sel->target != V4L2_SEL_TGT_COMPOSE) - return -EINVAL; - - if (vb2_is_busy(&vou_dev->queue)) - return -EBUSY; - - if (vou_dev->std & V4L2_STD_525_60) - img_height_max = 480; - else - img_height_max = 576; - - v4l_bound_align_image(&rect->width, - VOU_MIN_IMAGE_WIDTH, VOU_MAX_IMAGE_WIDTH, 1, - &rect->height, - VOU_MIN_IMAGE_HEIGHT, img_height_max, 1, 0); - - if (rect->width + rect->left > VOU_MAX_IMAGE_WIDTH) - rect->left = VOU_MAX_IMAGE_WIDTH - rect->width; - - if (rect->height + rect->top > img_height_max) - rect->top = img_height_max - rect->height; - - geo.output = *rect; - geo.in_width = pix->width; - geo.in_height = pix->height; - - /* Configure the encoder one-to-one, position at 0, ignore errors */ - sd_sel.r.width = geo.output.width; - sd_sel.r.height = geo.output.height; - /* - * We first issue a S_SELECTION, so that the subsequent S_FMT delivers the - * final encoder configuration. - */ - v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, pad, - set_selection, NULL, &sd_sel); - format.format.width = geo.output.width; - format.format.height = geo.output.height; - ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, pad, - set_fmt, NULL, &format); - /* Must be implemented, so, don't check for -ENOIOCTLCMD */ - if (ret < 0) - return ret; - - /* Sanity checks */ - if ((unsigned)format.format.width > VOU_MAX_IMAGE_WIDTH || - (unsigned)format.format.height > img_height_max || - format.format.code != MEDIA_BUS_FMT_YUYV8_2X8) - return -EIO; - - geo.output.width = format.format.width; - geo.output.height = format.format.height; - - /* - * No down-scaling. According to the API, current call has precedence: - * https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/crop.html#cropping-structures - */ - vou_adjust_input(&geo, vou_dev->std); - - /* We tried to preserve output rectangle, but it could have changed */ - vou_dev->rect = geo.output; - pix->width = geo.in_width; - pix->height = geo.in_height; - - sh_vou_configure_geometry(vou_dev, vou_dev->pix_idx, - geo.scale_idx_h, geo.scale_idx_v); - - return 0; -} - -static irqreturn_t sh_vou_isr(int irq, void *dev_id) -{ - struct sh_vou_device *vou_dev = dev_id; - static unsigned long j; - struct sh_vou_buffer *vb; - static int cnt; - u32 irq_status = sh_vou_reg_a_read(vou_dev, VOUIR), masked; - u32 vou_status = sh_vou_reg_a_read(vou_dev, VOUSTR); - - if (!(irq_status & 0x300)) { - if (printk_timed_ratelimit(&j, 500)) - dev_warn(vou_dev->v4l2_dev.dev, "IRQ status 0x%x!\n", - irq_status); - return IRQ_NONE; - } - - spin_lock(&vou_dev->lock); - if (!vou_dev->active || list_empty(&vou_dev->buf_list)) { - if (printk_timed_ratelimit(&j, 500)) - dev_warn(vou_dev->v4l2_dev.dev, - "IRQ without active buffer: %x!\n", irq_status); - /* Just ack: buf_release will disable further interrupts */ - sh_vou_reg_a_set(vou_dev, VOUIR, 0, 0x300); - spin_unlock(&vou_dev->lock); - return IRQ_HANDLED; - } - - masked = ~(0x300 & irq_status) & irq_status & 0x30304; - dev_dbg(vou_dev->v4l2_dev.dev, - "IRQ status 0x%x -> 0x%x, VOU status 0x%x, cnt %d\n", - irq_status, masked, vou_status, cnt); - - cnt++; - /* side = vou_status & 0x10000; */ - - /* Clear only set interrupts */ - sh_vou_reg_a_write(vou_dev, VOUIR, masked); - - vb = vou_dev->active; - if (list_is_singular(&vb->list)) { - /* Keep cycling while no next buffer is available */ - sh_vou_schedule_next(vou_dev, &vb->vb); - spin_unlock(&vou_dev->lock); - return IRQ_HANDLED; - } - - list_del(&vb->list); - - vb->vb.vb2_buf.timestamp = ktime_get_ns(); - vb->vb.sequence = vou_dev->sequence++; - vb->vb.field = V4L2_FIELD_INTERLACED; - vb2_buffer_done(&vb->vb.vb2_buf, VB2_BUF_STATE_DONE); - - vou_dev->active = list_entry(vou_dev->buf_list.next, - struct sh_vou_buffer, list); - - if (list_is_singular(&vou_dev->buf_list)) { - /* Keep cycling while no next buffer is available */ - sh_vou_schedule_next(vou_dev, &vou_dev->active->vb); - } else { - struct sh_vou_buffer *new = list_entry(vou_dev->active->list.next, - struct sh_vou_buffer, list); - sh_vou_schedule_next(vou_dev, &new->vb); - } - - spin_unlock(&vou_dev->lock); - - return IRQ_HANDLED; -} - -static int sh_vou_hw_init(struct sh_vou_device *vou_dev) -{ - struct sh_vou_pdata *pdata = vou_dev->pdata; - u32 voucr = sh_vou_ntsc_mode(pdata->bus_fmt) << 29; - int i = 100; - - /* Disable all IRQs */ - sh_vou_reg_a_write(vou_dev, VOUIR, 0); - - /* Reset VOU interfaces - registers unaffected */ - sh_vou_reg_a_write(vou_dev, VOUSRR, 0x101); - while (--i && (sh_vou_reg_a_read(vou_dev, VOUSRR) & 0x101)) - udelay(1); - - if (!i) - return -ETIMEDOUT; - - dev_dbg(vou_dev->v4l2_dev.dev, "Reset took %dus\n", 100 - i); - - if (pdata->flags & SH_VOU_PCLK_FALLING) - voucr |= 1 << 28; - if (pdata->flags & SH_VOU_HSYNC_LOW) - voucr |= 1 << 27; - if (pdata->flags & SH_VOU_VSYNC_LOW) - voucr |= 1 << 26; - sh_vou_reg_ab_set(vou_dev, VOUCR, voucr, 0xfc000000); - - /* Manual register side switching at first */ - sh_vou_reg_a_write(vou_dev, VOURCR, 4); - /* Default - fixed HSYNC length, can be made configurable is required */ - sh_vou_reg_ab_write(vou_dev, VOUMSR, 0x800000); - - sh_vou_set_fmt_vid_out(vou_dev, &vou_dev->pix); - - return 0; -} - -/* File operations */ -static int sh_vou_open(struct file *file) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - int err; - - if (mutex_lock_interruptible(&vou_dev->fop_lock)) - return -ERESTARTSYS; - - err = v4l2_fh_open(file); - if (err) - goto done_open; - if (v4l2_fh_is_singular_file(file) && - vou_dev->status == SH_VOU_INITIALISING) { - /* First open */ - err = pm_runtime_resume_and_get(vou_dev->v4l2_dev.dev); - if (err < 0) { - v4l2_fh_release(file); - goto done_open; - } - err = sh_vou_hw_init(vou_dev); - if (err < 0) { - pm_runtime_put(vou_dev->v4l2_dev.dev); - v4l2_fh_release(file); - } else { - vou_dev->status = SH_VOU_IDLE; - } - } -done_open: - mutex_unlock(&vou_dev->fop_lock); - return err; -} - -static int sh_vou_release(struct file *file) -{ - struct sh_vou_device *vou_dev = video_drvdata(file); - bool is_last; - - mutex_lock(&vou_dev->fop_lock); - is_last = v4l2_fh_is_singular_file(file); - _vb2_fop_release(file, NULL); - if (is_last) { - /* Last close */ - vou_dev->status = SH_VOU_INITIALISING; - sh_vou_reg_a_set(vou_dev, VOUER, 0, 0x101); - pm_runtime_put(vou_dev->v4l2_dev.dev); - } - mutex_unlock(&vou_dev->fop_lock); - return 0; -} - -/* sh_vou display ioctl operations */ -static const struct v4l2_ioctl_ops sh_vou_ioctl_ops = { - .vidioc_querycap = sh_vou_querycap, - .vidioc_enum_fmt_vid_out = sh_vou_enum_fmt_vid_out, - .vidioc_g_fmt_vid_out = sh_vou_g_fmt_vid_out, - .vidioc_s_fmt_vid_out = sh_vou_s_fmt_vid_out, - .vidioc_try_fmt_vid_out = sh_vou_try_fmt_vid_out, - .vidioc_reqbufs = vb2_ioctl_reqbufs, - .vidioc_create_bufs = vb2_ioctl_create_bufs, - .vidioc_querybuf = vb2_ioctl_querybuf, - .vidioc_qbuf = vb2_ioctl_qbuf, - .vidioc_dqbuf = vb2_ioctl_dqbuf, - .vidioc_prepare_buf = vb2_ioctl_prepare_buf, - .vidioc_streamon = vb2_ioctl_streamon, - .vidioc_streamoff = vb2_ioctl_streamoff, - .vidioc_expbuf = vb2_ioctl_expbuf, - .vidioc_g_output = sh_vou_g_output, - .vidioc_s_output = sh_vou_s_output, - .vidioc_enum_output = sh_vou_enum_output, - .vidioc_s_std = sh_vou_s_std, - .vidioc_g_std = sh_vou_g_std, - .vidioc_g_selection = sh_vou_g_selection, - .vidioc_s_selection = sh_vou_s_selection, - .vidioc_log_status = sh_vou_log_status, -}; - -static const struct v4l2_file_operations sh_vou_fops = { - .owner = THIS_MODULE, - .open = sh_vou_open, - .release = sh_vou_release, - .unlocked_ioctl = video_ioctl2, - .mmap = vb2_fop_mmap, - .poll = vb2_fop_poll, - .write = vb2_fop_write, -}; - -static const struct video_device sh_vou_video_template = { - .name = "sh_vou", - .fops = &sh_vou_fops, - .ioctl_ops = &sh_vou_ioctl_ops, - .tvnorms = V4L2_STD_525_60, /* PAL only supported in 8-bit non-bt656 mode */ - .vfl_dir = VFL_DIR_TX, - .device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_READWRITE | - V4L2_CAP_STREAMING, -}; - -static int sh_vou_probe(struct platform_device *pdev) -{ - struct sh_vou_pdata *vou_pdata = pdev->dev.platform_data; - struct v4l2_rect *rect; - struct v4l2_pix_format *pix; - struct i2c_adapter *i2c_adap; - struct video_device *vdev; - struct sh_vou_device *vou_dev; - struct resource *reg_res; - struct v4l2_subdev *subdev; - struct vb2_queue *q; - int irq, ret; - - reg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - irq = platform_get_irq(pdev, 0); - - if (!vou_pdata || !reg_res || irq <= 0) { - dev_err(&pdev->dev, "Insufficient VOU platform information.\n"); - return -ENODEV; - } - - vou_dev = devm_kzalloc(&pdev->dev, sizeof(*vou_dev), GFP_KERNEL); - if (!vou_dev) - return -ENOMEM; - - INIT_LIST_HEAD(&vou_dev->buf_list); - spin_lock_init(&vou_dev->lock); - mutex_init(&vou_dev->fop_lock); - vou_dev->pdata = vou_pdata; - vou_dev->status = SH_VOU_INITIALISING; - vou_dev->pix_idx = 1; - - rect = &vou_dev->rect; - pix = &vou_dev->pix; - - /* Fill in defaults */ - vou_dev->std = V4L2_STD_NTSC_M; - rect->left = 0; - rect->top = 0; - rect->width = VOU_MAX_IMAGE_WIDTH; - rect->height = 480; - pix->width = VOU_MAX_IMAGE_WIDTH; - pix->height = 480; - pix->pixelformat = V4L2_PIX_FMT_NV16; - pix->field = V4L2_FIELD_INTERLACED; - pix->bytesperline = VOU_MAX_IMAGE_WIDTH; - pix->sizeimage = VOU_MAX_IMAGE_WIDTH * 2 * 480; - pix->colorspace = V4L2_COLORSPACE_SMPTE170M; - - vou_dev->base = devm_ioremap_resource(&pdev->dev, reg_res); - if (IS_ERR(vou_dev->base)) - return PTR_ERR(vou_dev->base); - - ret = devm_request_irq(&pdev->dev, irq, sh_vou_isr, 0, "vou", vou_dev); - if (ret < 0) - return ret; - - ret = v4l2_device_register(&pdev->dev, &vou_dev->v4l2_dev); - if (ret < 0) { - dev_err(&pdev->dev, "Error registering v4l2 device\n"); - return ret; - } - - vdev = &vou_dev->vdev; - *vdev = sh_vou_video_template; - if (vou_pdata->bus_fmt == SH_VOU_BUS_8BIT) - vdev->tvnorms |= V4L2_STD_PAL; - vdev->v4l2_dev = &vou_dev->v4l2_dev; - vdev->release = video_device_release_empty; - vdev->lock = &vou_dev->fop_lock; - - video_set_drvdata(vdev, vou_dev); - - /* Initialize the vb2 queue */ - q = &vou_dev->queue; - q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_WRITE; - q->drv_priv = vou_dev; - q->buf_struct_size = sizeof(struct sh_vou_buffer); - q->ops = &sh_vou_qops; - q->mem_ops = &vb2_dma_contig_memops; - q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; - q->min_buffers_needed = 2; - q->lock = &vou_dev->fop_lock; - q->dev = &pdev->dev; - ret = vb2_queue_init(q); - if (ret) - goto ei2cgadap; - - vdev->queue = q; - INIT_LIST_HEAD(&vou_dev->buf_list); - - pm_runtime_enable(&pdev->dev); - pm_runtime_resume(&pdev->dev); - - i2c_adap = i2c_get_adapter(vou_pdata->i2c_adap); - if (!i2c_adap) { - ret = -ENODEV; - goto ei2cgadap; - } - - ret = sh_vou_hw_init(vou_dev); - if (ret < 0) - goto ereset; - - subdev = v4l2_i2c_new_subdev_board(&vou_dev->v4l2_dev, i2c_adap, - vou_pdata->board_info, NULL); - if (!subdev) { - ret = -ENOMEM; - goto ei2cnd; - } - - ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); - if (ret < 0) - goto evregdev; - - return 0; - -evregdev: -ei2cnd: -ereset: - i2c_put_adapter(i2c_adap); -ei2cgadap: - pm_runtime_disable(&pdev->dev); - v4l2_device_unregister(&vou_dev->v4l2_dev); - return ret; -} - -static int sh_vou_remove(struct platform_device *pdev) -{ - struct v4l2_device *v4l2_dev = platform_get_drvdata(pdev); - struct sh_vou_device *vou_dev = container_of(v4l2_dev, - struct sh_vou_device, v4l2_dev); - struct v4l2_subdev *sd = list_entry(v4l2_dev->subdevs.next, - struct v4l2_subdev, list); - struct i2c_client *client = v4l2_get_subdevdata(sd); - - pm_runtime_disable(&pdev->dev); - video_unregister_device(&vou_dev->vdev); - i2c_put_adapter(client->adapter); - v4l2_device_unregister(&vou_dev->v4l2_dev); - return 0; -} - -static struct platform_driver sh_vou = { - .remove = sh_vou_remove, - .driver = { - .name = "sh-vou", - }, -}; - -module_platform_driver_probe(sh_vou, sh_vou_probe); - -MODULE_DESCRIPTION("SuperH VOU driver"); -MODULE_AUTHOR("Guennadi Liakhovetski "); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION("0.1.0"); -MODULE_ALIAS("platform:sh-vou"); From patchwork Fri Jan 13 06:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 644791 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60B81C678D6 for ; Fri, 13 Jan 2023 06:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241372AbjAMGad (ORCPT ); Fri, 13 Jan 2023 01:30:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240857AbjAMG1P (ORCPT ); Fri, 13 Jan 2023 01:27:15 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA4926B19F; Thu, 12 Jan 2023 22:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=V1vQGE3XW96qQp3ejFsm70w3mnOS9+pWBLCZirkv1tk=; b=2+SiOyCvTzvDZZCeuwWrAYwhzj EWAQESOIDtQymDuYM0T7JpVes3xvB7NFWQ+KmJV1uAOpOiRJUBjTMIMZUpzF2ix6MOt0hGo62CWng diwLKN81u+WjRqFmLkwMZ873sIws+XMLCIUxrN4I7r+ZaeFve8swojZ2Nb8EGuKmlXeIEB1nRyph2 AGmxrxbCZm5edKIVp4yRI47qeIEa85kNn0gl7iBuYuEaOtP2HtGe1Lkv6xia/XchQLm3DtxOaVah4 5sBY0LpYQziGvInjmbVYYVxDsXL3Jm0yMz0PJd+Su5dRSgTKQwyncOI0wCWZmAu3ILcI2jS/gxiK0 qG4NqsbA==; Received: from [2001:4bb8:181:656b:9509:7d20:8d39:f895] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGDUo-000m9z-Df; Fri, 13 Jan 2023 06:24:59 +0000 From: Christoph Hellwig To: Yoshinori Sato , Rich Felker , Arnd Bergmann , Greg Kroah-Hartman Cc: Laurent Pinchart , Kieran Bingham , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, linux-mmc@vger.kernel.org, linux-mtd@lists.infradead.org, netdev@vger.kernel.org, linux-gpio@vger.kernel.org, linux-rtc@vger.kernel.org, linux-spi@vger.kernel.org, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org, linux-sh@vger.kernel.org Subject: [PATCH 22/22] drivers: platform: remove early_platform_cleanup Date: Fri, 13 Jan 2023 07:23:39 +0100 Message-Id: <20230113062339.1909087-23-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113062339.1909087-1-hch@lst.de> References: <20230113062339.1909087-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This weak stub was only overriden by the now remove sh architecture. Signed-off-by: Christoph Hellwig --- drivers/base/platform.c | 4 ---- include/linux/platform_device.h | 3 --- 2 files changed, 7 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 968f3d71eeab2e..eb3feabf6c2f53 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1506,14 +1506,10 @@ struct device *platform_find_device_by_driver(struct device *start, } EXPORT_SYMBOL_GPL(platform_find_device_by_driver); -void __weak __init early_platform_cleanup(void) { } - int __init platform_bus_init(void) { int error; - early_platform_cleanup(); - error = device_register(&platform_bus); if (error) { put_device(&platform_bus); diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 894939a74dd20f..86692f730e3a12 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h @@ -352,7 +352,4 @@ extern int platform_pm_restore(struct device *dev); #define USE_PLATFORM_PM_SLEEP_OPS #endif -/* For now only SuperH uses it */ -void early_platform_cleanup(void); - #endif /* _PLATFORM_DEVICE_H_ */