public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Hogan <jhogan@kernel.org>
To: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
Cc: linux-mips@linux-mips.org, Miodrag Dinic <miodrag.dinic@mips.com>,
	Goran Ferenc <goran.ferenc@mips.com>,
	Aleksandar Markovic <aleksandar.markovic@mips.com>,
	"David S. Miller" <davem@davemloft.net>,
	Douglas Leung <douglas.leung@mips.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Paul Burton <paul.burton@mips.com>,
	Petar Jovanovic <petar.jovanovic@mips.com>,
	Raghu Gandham <raghu.gandham@mips.com>,
	Ralf Baechle <ralf@linux-mips.org>,
	Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH v12 3/3] MIPS: ranchu: Add Ranchu as a new generic-based board
Date: Thu, 1 Feb 2018 16:05:54 +0000	[thread overview]
Message-ID: <20180201160553.GL7637@saruman> (raw)
In-Reply-To: <1514562138-13774-4-git-send-email-aleksandar.markovic@rt-rk.com>

[-- Attachment #1: Type: text/plain, Size: 8644 bytes --]

On Fri, Dec 29, 2017 at 04:41:47PM +0100, Aleksandar Markovic wrote:
> From: Miodrag Dinic <miodrag.dinic@mips.com>
> 
> Provide amendments to the MIPS generic platform framework so that
> the new generic-based board Ranchu can be chosen to be built.
> 
> The Ranchu board is intended to be used by Android emulator. The name
> "Ranchu" originates from Android development community. "Goldfish" and
> "Ranchu" are terms used for two generations of virtual boards used by
> Android emulator. The name "Ranchu" is a newer one among the two, and
> this patch deals with Ranchu. However, for historical reasons, some
> devices/drivers still contain the name "Goldfish".
> 
> MIPS Ranchu machine includes a number of Goldfish devices. The support
> for Virtio devices is also included. Ranchu board supports up to 16
> Virtio devices which can be attached using Virtio MMIO Bus. This is
> summarized in the following picture:
> 
>        ABUS
>         ||----MIPS CPU
>         ||       |                    IRQs
>         ||----Goldfish PIC------------(32)--------
>         ||                     | | | | | | | | |
>         ||----Goldfish TTY------ | | | | | | | |
>         ||                       | | | | | | | |
>         ||----Goldfish RTC-------- | | | | | | |
>         ||                         | | | | | | |
>         ||----Goldfish FB----------- | | | | | |
>         ||                           | | | | | |
>         ||----Goldfish Events--------- | | | | |
>         ||                             | | | | |
>         ||----Goldfish Audio------------ | | | |
>         ||                               | | | |
>         ||----Goldfish Battery------------ | | |
>         ||                                 | | |
>         ||----Android PIPE------------------ | |
>         ||                                   | |
>         ||----Virtio MMIO Bus                | |
>         ||    |    |    |                    | |
>         ||    |    |   (virtio-block)--------- |
>         ||   (16)  |                           |
>         ||    |   (virtio-net)------------------
> 
> Device Tree is created on the QEMU side based on the information about
> devices IO map and IRQ numbers. Kernel will load this DTB using UHI
> boot protocol DTB handover mode.
> 
> Signed-off-by: Miodrag Dinic <miodrag.dinic@mips.com>
> Signed-off-by: Goran Ferenc <goran.ferenc@mips.com>
> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@mips.com>
> Reviewed-by: James Hogan <jhogan@kernel.org>

Applied to my 4.16 branch,

Thanks
James

> ---
>  MAINTAINERS                                   |  7 ++
>  arch/mips/configs/generic/board-ranchu.config | 30 +++++++++
>  arch/mips/generic/Kconfig                     | 10 +++
>  arch/mips/generic/Makefile                    |  1 +
>  arch/mips/generic/board-ranchu.c              | 92 +++++++++++++++++++++++++++
>  5 files changed, 140 insertions(+)
>  create mode 100644 arch/mips/configs/generic/board-ranchu.config
>  create mode 100644 arch/mips/generic/board-ranchu.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e163873..95679c4 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -11442,6 +11442,13 @@ S:	Maintained
>  F:	Documentation/blockdev/ramdisk.txt
>  F:	drivers/block/brd.c
>  
> +RANCHU VIRTUAL BOARD FOR MIPS
> +M:	Miodrag Dinic <miodrag.dinic@mips.com>
> +L:	linux-mips@linux-mips.org
> +S:	Supported
> +F:	arch/mips/generic/board-ranchu.c
> +F:	arch/mips/configs/generic/board-ranchu.config
> +
>  RANDOM NUMBER DRIVER
>  M:	"Theodore Ts'o" <tytso@mit.edu>
>  S:	Maintained
> diff --git a/arch/mips/configs/generic/board-ranchu.config b/arch/mips/configs/generic/board-ranchu.config
> new file mode 100644
> index 0000000..fee9ad4
> --- /dev/null
> +++ b/arch/mips/configs/generic/board-ranchu.config
> @@ -0,0 +1,30 @@
> +CONFIG_VIRT_BOARD_RANCHU=y
> +
> +CONFIG_BATTERY_GOLDFISH=y
> +CONFIG_FB=y
> +CONFIG_FB_GOLDFISH=y
> +CONFIG_GOLDFISH=y
> +CONFIG_STAGING=y
> +CONFIG_GOLDFISH_AUDIO=y
> +CONFIG_GOLDFISH_PIC=y
> +CONFIG_GOLDFISH_PIPE=y
> +CONFIG_GOLDFISH_TTY=y
> +CONFIG_RTC_CLASS=y
> +CONFIG_RTC_DRV_GOLDFISH=y
> +
> +CONFIG_INPUT_EVDEV=y
> +CONFIG_INPUT_KEYBOARD=y
> +CONFIG_KEYBOARD_GOLDFISH_EVENTS=y
> +
> +CONFIG_MAGIC_SYSRQ=y
> +CONFIG_POWER_SUPPLY=y
> +CONFIG_POWER_RESET=y
> +CONFIG_POWER_RESET_SYSCON=y
> +CONFIG_POWER_RESET_SYSCON_POWEROFF=y
> +
> +CONFIG_VIRTIO_BLK=y
> +CONFIG_VIRTIO_CONSOLE=y
> +CONFIG_VIRTIO_MMIO=y
> +CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
> +CONFIG_NETDEVICES=y
> +CONFIG_VIRTIO_NET=y
> diff --git a/arch/mips/generic/Kconfig b/arch/mips/generic/Kconfig
> index 52e0286..2ff3b17 100644
> --- a/arch/mips/generic/Kconfig
> +++ b/arch/mips/generic/Kconfig
> @@ -49,4 +49,14 @@ config FIT_IMAGE_FDT_XILFPGA
>  	  Enable this to include the FDT for the MIPSfpga platform
>  	  from Imagination Technologies in the FIT kernel image.
>  
> +config VIRT_BOARD_RANCHU
> +	bool "Support Ranchu platform for Android emulator"
> +	help
> +	  This enables support for the platform used by Android emulator.
> +
> +	  Ranchu platform consists of a set of virtual devices. This platform
> +	  enables emulation of variety of virtual configurations while using
> +	  Android emulator. Android emulator is based on Qemu, and contains
> +	  the support for the same set of virtual devices.
> +
>  endif
> diff --git a/arch/mips/generic/Makefile b/arch/mips/generic/Makefile
> index 8749673..5fb60c8 100644
> --- a/arch/mips/generic/Makefile
> +++ b/arch/mips/generic/Makefile
> @@ -15,3 +15,4 @@ obj-y += proc.o
>  obj-$(CONFIG_YAMON_DT_SHIM)		+= yamon-dt.o
>  obj-$(CONFIG_LEGACY_BOARD_SEAD3)	+= board-sead3.o
>  obj-$(CONFIG_KEXEC)			+= kexec.o
> +obj-$(CONFIG_VIRT_BOARD_RANCHU)	+= board-ranchu.o
> diff --git a/arch/mips/generic/board-ranchu.c b/arch/mips/generic/board-ranchu.c
> new file mode 100644
> index 0000000..ea451b8
> --- /dev/null
> +++ b/arch/mips/generic/board-ranchu.c
> @@ -0,0 +1,92 @@
> +/*
> + * Support code for virtual Ranchu board for MIPS.
> + *
> + * Author: Miodrag Dinic <miodrag.dinic@mips.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation;  either version 2 of the  License, or (at your
> + * option) any later version.
> + */
> +
> +#include <linux/of_address.h>
> +#include <linux/types.h>
> +
> +#include <asm/machine.h>
> +#include <asm/mipsregs.h>
> +#include <asm/time.h>
> +
> +#define GOLDFISH_TIMER_LOW		0x00
> +#define GOLDFISH_TIMER_HIGH		0x04
> +
> +static __init u64 read_rtc_time(void __iomem *base)
> +{
> +	u32 time_low;
> +	u32 time_high;
> +
> +	/*
> +	 * Reading the low address latches the high value
> +	 * as well so there is no fear that we may read
> +	 * inaccurate high value.
> +	 */
> +	time_low = readl(base + GOLDFISH_TIMER_LOW);
> +	time_high = readl(base + GOLDFISH_TIMER_HIGH);
> +
> +	return ((u64)time_high << 32) | time_low;
> +}
> +
> +static __init unsigned int ranchu_measure_hpt_freq(void)
> +{
> +	u64 rtc_start, rtc_current, rtc_delta;
> +	unsigned int start, count;
> +	struct device_node *np;
> +	void __iomem *rtc_base;
> +
> +	np = of_find_compatible_node(NULL, NULL, "google,goldfish-rtc");
> +	if (!np)
> +		panic("%s(): Failed to find 'google,goldfish-rtc' dt node!",
> +		      __func__);
> +
> +	rtc_base = of_iomap(np, 0);
> +	if (!rtc_base)
> +		panic("%s(): Failed to ioremap Goldfish RTC base!", __func__);
> +
> +	/*
> +	 * Poll the nanosecond resolution RTC for one
> +	 * second to calibrate the CPU frequency.
> +	 */
> +	rtc_start = read_rtc_time(rtc_base);
> +	start = read_c0_count();
> +
> +	do {
> +		rtc_current = read_rtc_time(rtc_base);
> +		rtc_delta = rtc_current - rtc_start;
> +	} while (rtc_delta < NSEC_PER_SEC);
> +
> +	count = read_c0_count() - start;
> +
> +	/*
> +	 * Make sure the frequency will be a round number.
> +	 * Without this correction, the returned value may vary
> +	 * between subsequent emulation executions.
> +	 *
> +	 * TODO: Set this value using device tree.
> +	 */
> +	count += 5000;
> +	count -= count % 10000;
> +
> +	iounmap(rtc_base);
> +
> +	return count;
> +}
> +
> +static const struct of_device_id ranchu_of_match[] __initconst = {
> +	{
> +		.compatible = "mti,ranchu",
> +	},
> +};
> +
> +MIPS_MACHINE(ranchu) = {
> +	.matches = ranchu_of_match,
> +	.measure_hpt_freq = ranchu_measure_hpt_freq,
> +};
> -- 
> 2.7.4
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2018-02-01 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-29 15:41 [PATCH v12 0/3] MIPS: Add virtual Ranchu board as a generic-based board Aleksandar Markovic
2017-12-29 15:41 ` [PATCH v12 1/3] Documentation: Add device tree binding for Goldfish PIC driver Aleksandar Markovic
2017-12-29 15:41 ` [PATCH v12 2/3] irqchip/irq-goldfish-pic: Add " Aleksandar Markovic
2017-12-29 15:41 ` [PATCH v12 3/3] MIPS: ranchu: Add Ranchu as a new generic-based board Aleksandar Markovic
2018-02-01 16:05   ` James Hogan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180201160553.GL7637@saruman \
    --to=jhogan@kernel.org \
    --cc=aleksandar.markovic@mips.com \
    --cc=aleksandar.markovic@rt-rk.com \
    --cc=davem@davemloft.net \
    --cc=douglas.leung@mips.com \
    --cc=goran.ferenc@mips.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=mchehab@kernel.org \
    --cc=miodrag.dinic@mips.com \
    --cc=paul.burton@mips.com \
    --cc=petar.jovanovic@mips.com \
    --cc=raghu.gandham@mips.com \
    --cc=ralf@linux-mips.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox