[RFC 5/5] ipmi:bt-bmc: Add Microwatt

Cédric Le Goater clg at kaod.org
Wed Oct 6 17:00:40 AEDT 2021


On 10/6/21 04:12, Anton Blanchard wrote:
> This adds the Microwatt specific bits, including interrupt support.
> 
> Signed-off-by: Anton Blanchard <anton at ozlabs.org>
> ---
>   .../devicetree/bindings/ipmi/ibt-bmc.txt      |  1 +
>   drivers/char/ipmi/Kconfig                     |  8 ++-
>   drivers/char/ipmi/bt-bmc.c                    | 69 +++++++++++++++++++
>   3 files changed, 75 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/ipmi/ibt-bmc.txt b/Documentation/devicetree/bindings/ipmi/ibt-bmc.txt
> index 78ee716a950e..1b661daf0193 100644
> --- a/Documentation/devicetree/bindings/ipmi/ibt-bmc.txt
> +++ b/Documentation/devicetree/bindings/ipmi/ibt-bmc.txt
> @@ -9,6 +9,7 @@ Required properties:
>   - compatible : should be one of
>   	"aspeed,ast2400-ibt-bmc"
>   	"aspeed,ast2500-ibt-bmc"
> +	"ibm,microwatt-ibt-bmc"
>   - reg: physical address and size of the registers
>   
>   Optional properties:
> diff --git a/drivers/char/ipmi/Kconfig b/drivers/char/ipmi/Kconfig
> index 8b2f0f675e5f..079302f4eef2 100644
> --- a/drivers/char/ipmi/Kconfig
> +++ b/drivers/char/ipmi/Kconfig
> @@ -152,13 +152,15 @@ config IPMI_KCS_BMC_SERIO
>   	  called kcs_bmc_serio.
>   
>   config BT_IPMI_BMC
> -	depends on ARCH_ASPEED || COMPILE_TEST
> +	depends on ARCH_ASPEED || PPC_MICROWATT || COMPILE_TEST
>   	depends on REGMAP && REGMAP_MMIO && MFD_SYSCON
>   	tristate "BT IPMI bmc driver"
>   	help
>   	  Provides a driver for the BT (Block Transfer) IPMI interface
> -	  found on Aspeed SOCs (AST2400 and AST2500). The driver
> -	  implements the BMC side of the BT interface.
> +	  found on Aspeed SOCs (AST2400 and AST2500) as well as the OpenPOWER
> +	  LPC peripheral macro at
> +	  <https://github.com/OpenPOWERFoundation/lpcperipheral>
> +	  The driver implements the BMC side of the BT interface.
>   
>   config IPMB_DEVICE_INTERFACE
>   	tristate 'IPMB Interface handler'
> diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c
> index b48e04405ac4..24327b57c60b 100644
> --- a/drivers/char/ipmi/bt-bmc.c
> +++ b/drivers/char/ipmi/bt-bmc.c
> @@ -41,6 +41,11 @@
>   #define   BT_CR2_IRQ_HBUSY	0x40
>   #define ASPEED_BT_CR3	0xc
>   
> +#define MICROWATT_IRQ_MASK	0x0
> +#define MICROWATT_IRQ_STATUS	0x4
> +#define   IRQ_HOST_TO_BMC_ATTN	0x1
> +#define   IRQ_HOST_NOT_BUSY	0x2
> +
>   #define BT_CTRL		0x10
>   #define   BT_CTRL_B_BUSY		0x80
>   #define   BT_CTRL_H_BUSY		0x40
> @@ -395,6 +400,27 @@ static irqreturn_t aspeed_bt_bmc_irq(int irq, void *arg)
>   	return IRQ_HANDLED;
>   }
>   
> +static irqreturn_t microwatt_bt_bmc_irq(int irq, void *arg)
> +{
> +	struct bt_bmc *bt_bmc = arg;
> +	u32 reg;
> +	int rc;
> +
> +	rc = regmap_read(bt_bmc->map, bt_bmc->offset + MICROWATT_IRQ_STATUS, &reg);
> +	if (rc)
> +		return IRQ_NONE;
> +
> +	/* Interrupt wasn't something we knew about */
> +	if (!(reg & (IRQ_HOST_TO_BMC_ATTN | IRQ_HOST_NOT_BUSY)))
> +		return IRQ_NONE;
> +
> +	/* ack all pending IRQs */
> +	regmap_write(bt_bmc->map, bt_bmc->offset + MICROWATT_IRQ_STATUS, 0);
> +
> +	wake_up(&bt_bmc->queue);
> +	return IRQ_HANDLED;
> +}
> +
>   static int aspeed_bt_bmc_config_irq(struct bt_bmc *bt_bmc,
>   			     struct platform_device *pdev)
>   {
> @@ -446,6 +472,48 @@ static const struct bt_bmc_ops aspeed_bt_bmc_ops = {
>   	.enable_bt = aspeed_enable_bt,
>   };
>   
> +static int microwatt_bt_bmc_config_irq(struct bt_bmc *bt_bmc,
> +			     struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	int rc;
> +
> +	bt_bmc->irq = platform_get_irq_optional(pdev, 0);
> +	if (bt_bmc->irq < 0)
> +		return bt_bmc->irq;
> +
> +	rc = devm_request_irq(dev, bt_bmc->irq, microwatt_bt_bmc_irq, IRQF_SHARED,
> +			      DEVICE_NAME, bt_bmc);
> +	if (rc < 0) {
> +		dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq);
> +		bt_bmc->irq = rc;
> +		return rc;
> +	}
> +
> +	/*
> +	 * Configure the hardware to give us an interrupt whenever the H2B
> +	 * bit is set or the HBUSY bit is cleared.
> +	 *
> +	 * H2B will be asserted when the bmc has data for us; HBUSY
> +	 * will be cleared (along with B2H) when we can write the next
> +	 * message to the BT buffer
> +	 */
> +	rc = regmap_update_bits(bt_bmc->map, bt_bmc->offset + MICROWATT_IRQ_MASK,
> +				(IRQ_HOST_TO_BMC_ATTN | IRQ_HOST_NOT_BUSY),
> +				(IRQ_HOST_TO_BMC_ATTN | IRQ_HOST_NOT_BUSY));

This is the only difference. May be we could introduce a ->config_irq_hw()
handler to keep a larger part common. No big deal.

Reviewed-by: Cédric Le Goater <clg at kaod.org>

C.


> +	return rc;
> +}
> +
> +static void microwatt_enable_bt(struct bt_bmc *bt_bmc)
> +{
> +}
> +
> +static const struct bt_bmc_ops microwatt_bt_bmc_ops = {
> +	.config_irq = microwatt_bt_bmc_config_irq,
> +	.enable_bt = microwatt_enable_bt,
> +};
> +
>   static int bt_bmc_probe(struct platform_device *pdev)
>   {
>   	struct bt_bmc *bt_bmc;
> @@ -530,6 +598,7 @@ static int bt_bmc_remove(struct platform_device *pdev)
>   static const struct of_device_id bt_bmc_match[] = {
>   	{ .compatible = "aspeed,ast2400-ibt-bmc", .data = &aspeed_bt_bmc_ops },
>   	{ .compatible = "aspeed,ast2500-ibt-bmc", .data = &aspeed_bt_bmc_ops },
> +	{ .compatible = "ibm,microwatt-ibt-bmc", .data = &microwatt_bt_bmc_ops },
>   	{ },
>   };
>   
> 



More information about the Linuxppc-dev mailing list