From tmaimon77 at gmail.com Fri Dec 1 04:15:21 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 30 Nov 2023 19:15:21 +0200 Subject: [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: References: <20231121151733.2015384-1-tmaimon77@gmail.com> <20231121151733.2015384-3-tmaimon77@gmail.com> Message-ID: Hi Russell, On Mon, 27 Nov 2023 at 17:58, Russell King (Oracle) wrote: > > On Wed, Nov 22, 2023 at 07:23:28PM +0200, Tomer Maimon wrote: > > Hi Russell, > > > > Thanks for your comments. > > > > On Tue, 21 Nov 2023 at 17:45, Russell King (Oracle) > > wrote: > > > > > > On Tue, Nov 21, 2023 at 05:17:33PM +0200, Tomer Maimon wrote: > > > > Add Nuvoton NPCM BMC SoCs support to STMMAC dwmac driver. > > > > > > > > And modify MAINTAINERS to add a new F: entry for this driver. > > > > > > > > Signed-off-by: Tomer Maimon > > > > > > A few comments on this... > > > > > > > +#define IND_AC_BA_REG 0x1FE > > > > +#define SR_MII_CTRL 0x3E0000 > > > > + > > > > +#define PCS_SR_MII_CTRL_REG 0x0 > > > > +#define PCS_SPEED_SELECT6 BIT(6) > > > > +#define PCS_AN_ENABLE BIT(12) > > > > +#define PCS_SPEED_SELECT13 BIT(13) > > > > +#define PCS_RST BIT(15) > > > > > > include/uapi/linux/mii.h: > > > > > > #define BMCR_SPEED1000 0x0040 /* MSB of Speed (1000) */ > > > #define BMCR_ANENABLE 0x1000 /* Enable auto negotiation */ > > > #define BMCR_SPEED100 0x2000 /* Select 100Mbps */ > > > #define BMCR_RESET 0x8000 /* Reset to default state */ > > > > > > Look familiar? Maybe use the standard definitions for a standardised > > > register? > > > > > > > +void npcm_dwmac_pcs_init(struct npcm_dwmac *dwmac, struct device *dev, > > > > + struct plat_stmmacenet_data *plat_dat) > > > > +{ > > > > + u16 val; > > > > + > > > > + iowrite16((u16)(SR_MII_CTRL >> 9), dwmac->reg + IND_AC_BA_REG); > > > > + val = ioread16(dwmac->reg + PCS_SR_MII_CTRL_REG); > > > > + val |= PCS_RST; > > > > + iowrite16(val, dwmac->reg + PCS_SR_MII_CTRL_REG); > > > > + > > > > + while (val & PCS_RST) > > > > + val = ioread16(dwmac->reg + PCS_SR_MII_CTRL_REG); > > > > > > What if the PCS never clears its reset bit? Maybe use > > > read_poll_timeout() ? > > > > > > > + > > > > + val &= ~(PCS_AN_ENABLE); > > > > + iowrite16(val, dwmac->reg + PCS_SR_MII_CTRL_REG); > > > > +} > > > > > > Also, maybe it's time to require new stmmac platform support to start > > > making use of the phylink PCS support rather than continuing to code its > > > own? > > > > > > I notice, however, that you always disable inband signalling - please > > > explain why. Also, what protocol does the PCS use when communicating > > > with the PHY? > > With disable inband signalling you mean disable auto negotiation? > > Over a SGMII, 1000base-X, USXGMII etc link, there is an inband > signalling method. Whether it is "auto negotiation" depends on your > point of view. > > With 1000base-X, it is "auto negotiation" because the two link partners > advertise their abilities, and resolve the operational link parameters. > In essence, there is a negotiation between both ends. > > In the case of e.g. Cisco SGMII, "auto negotiation" is a total misnomer. > There is no "negotiation". The SGMII PHY side re-purposes the 1000base-X > inband 16-bit control word to inform the MAC about the negotiated > speed and duplex settings, and the MAC can only say "yes thank you for > that" back to the PHY. There is no "and this is what I'm doing" to it. > So there's no "negotiation" in SGMII. > > So, I prefer using "inband signalling" because that more accurately > describes both of these situations, whereas "auto negotiation" does > not. > > Note also that whenever I see "SGMII", that means Cisco's SGMII, > which is 1000base-X modified by Cisco, and doesn't include the IEEE > 802.3 1000base-X. > > > if > > yes it is because the PCS sgmii is connected to the external phy AN > > and is not working between the PCS and external phy. > > What if the external PHY wants to use Cisco SGMII inband signalling? This is not working with the external PHY we using (BCM54210S) and this is why we disable the inband signalling in the PCS. > > accessing the PCS registers is indirect. The top 13 bits (bits 21-9) > > of the offset have to be written to Indirect Access Base register > > bits 12:0 before indirectly accessing the target register with the > > offset of the bottom 9 bits (8:0) of the offset > > I'm not sure how this connects with my email. I asked what protocol > is used between the PCS and PHY, and I _think_ you've said that it's > Cisco SGMII. > > Please give details of which PHY is being used - I'd like to know > more about why the inband signalling isn't being used. We are using BRCM PHY, BCM54210S. > > Thanks. > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! Thanks, Tomer From tmaimon77 at gmail.com Fri Dec 1 04:17:22 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 30 Nov 2023 19:17:22 +0200 Subject: [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: References: <20231121151733.2015384-1-tmaimon77@gmail.com> <20231121151733.2015384-3-tmaimon77@gmail.com> <6aeb28f5-04c2-4723-9da2-d168025c307c@lunn.ch> <9ad42fef-b210-496a-aafc-eb2a7416c4df@lunn.ch> Message-ID: Hi Andrew, On Wed, 29 Nov 2023 at 01:31, Andrew Lunn wrote: > > On Mon, Nov 27, 2023 at 05:19:15PM +0200, Tomer Maimon wrote: > > Hi Andrew, > > > > I took a look at the xpcs driver and the stmmac driver and it doesn't > > cover NPCM use. > > > > in the NPCM case the stmmac ID=0x37 therefore the driver is linked to DWMAC1000 > > https://elixir.bootlin.com/linux/v6.7-rc2/source/drivers/net/ethernet/stmicro/stmmac/hwif.c#L139 > > > > to enable the xpcs, the stmmac should support xgmac or gmac4 and in > > the NPCM is support only gmac. > > https://elixir.bootlin.com/linux/v6.7-rc2/source/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c#L555 > > https://elixir.bootlin.com/linux/v6.7-rc2/source/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c#L573 > > > > and the most important thing is that the XPCS is handled through an > > indirect register access and not through MDIO. the MDIO is connected > > to the external PHY and not to the XPCS. > > What really matters here is, is the PCS hardware block you have an > XPCS? We don't want two drivers for the same block of hardware. > > MDIO vs indirect register access can be solved with a bit of > layering. That is not a reason to write a second driver. I will check with the xpcs maintainer how can we add indirect access to the xpcs module. > > Andrew Thanks. Tomer From andrew at lunn.ch Fri Dec 1 04:26:13 2023 From: andrew at lunn.ch (Andrew Lunn) Date: Thu, 30 Nov 2023 18:26:13 +0100 Subject: [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: References: <20231121151733.2015384-1-tmaimon77@gmail.com> <20231121151733.2015384-3-tmaimon77@gmail.com> <6aeb28f5-04c2-4723-9da2-d168025c307c@lunn.ch> <9ad42fef-b210-496a-aafc-eb2a7416c4df@lunn.ch> Message-ID: <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> > I will check with the xpcs maintainer how can we add indirect access > to the xpcs module. https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c#L449 It creates a regmap for the memory range. On top of that it creates an MDIO bus. You can then access the PCS in the normal way. Andrew From tmaimon77 at gmail.com Fri Dec 1 05:25:06 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 30 Nov 2023 20:25:06 +0200 Subject: [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> References: <20231121151733.2015384-1-tmaimon77@gmail.com> <20231121151733.2015384-3-tmaimon77@gmail.com> <6aeb28f5-04c2-4723-9da2-d168025c307c@lunn.ch> <9ad42fef-b210-496a-aafc-eb2a7416c4df@lunn.ch> <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> Message-ID: Hi Andrew, Thanks for your input. On Thu, 30 Nov 2023 at 19:26, Andrew Lunn wrote: > > > I will check with the xpcs maintainer how can we add indirect access > > to the xpcs module. > > https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c#L449 > > It creates a regmap for the memory range. On top of that it creates an > MDIO bus. You can then access the PCS in the normal way. > > Andrew Best Regards, Tomer From fancer.lancer at gmail.com Fri Dec 1 06:59:32 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 30 Nov 2023 22:59:32 +0300 Subject: [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> References: <20231121151733.2015384-1-tmaimon77@gmail.com> <20231121151733.2015384-3-tmaimon77@gmail.com> <6aeb28f5-04c2-4723-9da2-d168025c307c@lunn.ch> <9ad42fef-b210-496a-aafc-eb2a7416c4df@lunn.ch> <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> Message-ID: On Thu, Nov 30, 2023 at 06:26:13PM +0100, Andrew Lunn wrote: > > I will check with the xpcs maintainer how can we add indirect access > > to the xpcs module. > > https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c#L449 > > It creates a regmap for the memory range. On top of that it creates an > MDIO bus. You can then access the PCS in the normal way. Actually Synopsys DW XPCS can be synthesized with two types of the CSR interfaces: 1. MDIO: device looks as a normal MDIO device. This option is currently supported by the STMMAC MDIO driver. 2. MCI/APB3: device MMD CSRs are directly (all CSRs are visible) or indirectly (paged-base access) accessible over the system memory bus. In addition to the above XPCS device can be equipped with separate clock sources (at least to feed the MCI or APB3 interface) and may have dedicated IRQ line to signal various events like link establishing, failures, etc. From that perspective XPCS in both cases looks as a normal platform device for which would be better to have a special DT-node defined with all those resources supplied. Then the XPCS DT-node could be passed to the DW MAC DT-node via the already standardized "pcs-handle" DT-property. I have such approach implemented in my local repo. If you consider this as a proper solution, after a small modification I'll be able to submit a patchset for review tomorrow. -Serge(y) > > Andrew > From maxime.chevallier at bootlin.com Fri Dec 1 07:34:41 2023 From: maxime.chevallier at bootlin.com (Maxime Chevallier) Date: Thu, 30 Nov 2023 21:34:41 +0100 Subject: [Linux-stm32] [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: References: <20231121151733.2015384-1-tmaimon77@gmail.com> <20231121151733.2015384-3-tmaimon77@gmail.com> <6aeb28f5-04c2-4723-9da2-d168025c307c@lunn.ch> <9ad42fef-b210-496a-aafc-eb2a7416c4df@lunn.ch> <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> Message-ID: <20231130213441.032a661c@device.home> Hello, On Thu, 30 Nov 2023 22:59:32 +0300 Serge Semin wrote: > On Thu, Nov 30, 2023 at 06:26:13PM +0100, Andrew Lunn wrote: > > > I will check with the xpcs maintainer how can we add indirect access > > > to the xpcs module. > > > > https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c#L449 > > > > It creates a regmap for the memory range. On top of that it creates an > > MDIO bus. You can then access the PCS in the normal way. > > Actually Synopsys DW XPCS can be synthesized with two types of the CSR > interfaces: > 1. MDIO: device looks as a normal MDIO device. This option is currently > supported by the STMMAC MDIO driver. > 2. MCI/APB3: device MMD CSRs are directly (all CSRs are visible) or > indirectly (paged-base access) accessible over the system memory bus. > > In addition to the above XPCS device can be equipped with separate > clock sources (at least to feed the MCI or APB3 interface) and may > have dedicated IRQ line to signal various events like link > establishing, failures, etc. From that perspective XPCS in both cases > looks as a normal platform device for which would be better to have a > special DT-node defined with all those resources supplied. Then the > XPCS DT-node could be passed to the DW MAC DT-node via the already > standardized "pcs-handle" DT-property. To my understanding, this should work, there's another PCS that works this way : https://elixir.bootlin.com/linux/v6.7-rc3/source/drivers/net/pcs/pcs-rzn1-miic.c Are you still able to use the mdio-regmap glue that Andrew mentioned, to avoid the duplication between the mdio and mmio register accesses ? Maxime From quan at os.amperecomputing.com Fri Dec 1 17:31:22 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Fri, 1 Dec 2023 13:31:22 +0700 Subject: [PATCH] mctp i2c: Requeue the packet when arbitration is lost In-Reply-To: <852eaa7b5040124049e51ceba2d13a5799cb6748.camel@codeconstruct.com.au> References: <20231130075247.3078931-1-quan@os.amperecomputing.com> <473048522551f1cae5273eb4cd31b732d6e33e53.camel@codeconstruct.com.au> <706506b7-a89c-4dfc-b233-be7822eb056e@os.amperecomputing.com> <852eaa7b5040124049e51ceba2d13a5799cb6748.camel@codeconstruct.com.au> Message-ID: <3e8b18e6-673c-4ee6-a56b-08641c605efc@os.amperecomputing.com> On 30/11/2023 16:40, Jeremy Kerr wrote: > Hi Quan, > >> With this commit, we all see the packets go through peacefully just >> by requeueing the packets at MCTP layer and eliminated the need to >> retry in PLDM layer which would need more time. > > It's certainly possible that this tries harder to send MCTP packets, > but it's just duplicating the retry mechanism already present in the > i2c core. > > Why do we need another retry mechanism here? How is the i2c core retry > mechanism not sufficient? > > It would seem that you can get the same behaviour by adjusting the > retries/timeout limits in the core code, which has the advantage of > applying to all arbitration loss events on the i2c bus, not just for > MCTP tx. > Hi Jeremy, As per [1], __i2c_transfer() will retry for adap->retries times consecutively (without any wait) within the amount of time specified by adap->timeout. So as per my observation, once it loses the arbitration, the next retry is most likely still lost as another controller who win the arbitration may still be using the bus. Especially for upper layer protocol message like PLDM or SPDM, which size is far bigger than SMBus, usually ends up to queue several MCTP packets at a time. But if to requeue the packet, it must wait to acquire the lock before actually queueing that packet, and that is more likely to increase the chance to win the arbitration than to retry it right away as on the i2c core. Another reason is that, as i2c is widely used for many other applications, fixing the retry algorithm within the i2c core seems impossible. The other fact is that the initial default value of these two parameters depends on each type of controller; I'm not sure why yet. + i2c-aspeed: ? ? retries=0 timeout=1 sec [2] + i2c-cadence: ? ?retries=3 timeout=1 sec [3] + i2c-designware: retries=3 timeout=1 sec [4], [5] + i2c-emev2: ? ? ?retries=5 timeout=1 sec [6] + ... Unfortunately, in our case, we use i2c-aspeed, and there is only one try (see [2]), and that means we have only one single shot. I'm not sure why i2c-aspeed chose to set retries=0 by default, but I guess there must be a reason behind it. And yes, I agree, as per [7], these two parameters could be adjusted via ioctl() from userspace if the user wishes to change them. But, honestly, forcing users to change these parameters is not a good way, as I might have to say. To avoid that, requeueing the packet in the MCTP layer was kind of way better choice, and it was confirmed via our case. Thanks, - Quan [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/i2c-core-base.c#n2223 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-aspeed.c#n1030 [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-cadence.c#n1322 [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-designware-master.c#n1030 [5] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-designware-slave.c#n258 [6] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/busses/i2c-emev2.c#n385 [7] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/i2c/i2c-dev.c#n478 From jk at codeconstruct.com.au Fri Dec 1 19:38:29 2023 From: jk at codeconstruct.com.au (Jeremy Kerr) Date: Fri, 01 Dec 2023 16:38:29 +0800 Subject: [PATCH] mctp i2c: Requeue the packet when arbitration is lost In-Reply-To: <3e8b18e6-673c-4ee6-a56b-08641c605efc@os.amperecomputing.com> References: <20231130075247.3078931-1-quan@os.amperecomputing.com> <473048522551f1cae5273eb4cd31b732d6e33e53.camel@codeconstruct.com.au> <706506b7-a89c-4dfc-b233-be7822eb056e@os.amperecomputing.com> <852eaa7b5040124049e51ceba2d13a5799cb6748.camel@codeconstruct.com.au> <3e8b18e6-673c-4ee6-a56b-08641c605efc@os.amperecomputing.com> Message-ID: <10491ca5819563f98e2f4414836fd4da0c84c753.camel@codeconstruct.com.au> Hi Quan, > As per [1], __i2c_transfer() will retry for adap->retries times > consecutively (without any wait) within the amount of time specified > by adap->timeout. > > So as per my observation, once it loses the arbitration, the next > retry is most likely still lost as another controller who win the > arbitration may still be using the bus. In general (and specifically with your hardware setup), the controller should be waiting for a bus-idle state before attempting the retransmission. You may well hit another arbitration loss after that, but it won't be from the same bus activity. > Especially for upper layer protocol message like PLDM or SPDM, which > size is far bigger than SMBus, usually ends up to queue several MCTP > packets at a time. But if to requeue the packet, it must wait to > acquire the lock ... you're relying on the delay of acquiring a spinlock? The only contention on that lock is from local packets being sent to the device (and, in heavy TX backlogs, the netif queue will be stopped, so that lock will be uncontended). That sounds fairly fragile, and somewhat disconnected from the goal of waiting for a bus idle state. > before actually queueing that packet, and that is > more likely to increase the chance to win the arbitration than to > retry it right away as on the i2c core. > > Another reason is that, as i2c is widely used for many other > applications, fixing the retry algorithm within the i2c core seems > impossible. What needs fixing there? You haven't identified any issue with it. > The other fact is that the initial default value of these two > parameters > depends on each type of controller; I'm not sure why yet. > > + i2c-aspeed: ? ? retries=0 timeout=1 sec [2] > + i2c-cadence: ? ?retries=3 timeout=1 sec [3] > + i2c-designware: retries=3 timeout=1 sec [4], [5] > + i2c-emev2: ? ? ?retries=5 timeout=1 sec [6] > + ... > > Unfortunately, in our case, we use i2c-aspeed, and there is only one > try (see [2]), and that means we have only one single shot. I'm not > sure why i2c-aspeed chose to set retries=0 by default, but I guess > there must be a reason behind it. I would suggest that the actual fix you want here is to increase that retry count, rather than working-around your "not sure" points above with a duplication of the common retry mechanism. > And yes, I agree, as per [7], these two parameters could be adjusted > via ioctl() from userspace if the user wishes to change them. But, > honestly, forcing users to change these parameters is not a good way, > as I might have to say. But now you're forcing users to use your infinite-retry mechanism instead. We already have a retry mechanism, which is user-configurable, and we can set per-controller defaults. If you believe the defaults (present in the aspeed driver) are not suitable, and it's too onerous for users to adjust, then I would suggest proposing a change to the default. Your requeue approach has a problem, in that there is no mechanism for recovery on repeated packet contention. In a scenario where a specific packet always causes contention (say, a faulty device on the bus attempts to respond to that packet too early), then the packet is never dequeued; other packets already queued will be blocked behind this one packet. The only way to make forward progress from there is to fill the TX queue completely. You could address that by limiting the retries and/or having a timeout, but then you may as well just use the existing retry mechanism that we already have, which already does that. > To avoid that, requeueing the packet in the MCTP layer was kind of > way better choice, and it was confirmed via our case. Your earlier examples showed a max of one retry was needed for recovery. I would suggest bumping the i2c-aspeed driver default to suit the other in-tree controllers would be a much more appropriate fix. Cheers, Jeremy From quan at os.amperecomputing.com Fri Dec 1 22:47:30 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Fri, 1 Dec 2023 18:47:30 +0700 Subject: [PATCH] mctp i2c: Requeue the packet when arbitration is lost In-Reply-To: <10491ca5819563f98e2f4414836fd4da0c84c753.camel@codeconstruct.com.au> References: <20231130075247.3078931-1-quan@os.amperecomputing.com> <473048522551f1cae5273eb4cd31b732d6e33e53.camel@codeconstruct.com.au> <706506b7-a89c-4dfc-b233-be7822eb056e@os.amperecomputing.com> <852eaa7b5040124049e51ceba2d13a5799cb6748.camel@codeconstruct.com.au> <3e8b18e6-673c-4ee6-a56b-08641c605efc@os.amperecomputing.com> <10491ca5819563f98e2f4414836fd4da0c84c753.camel@codeconstruct.com.au> Message-ID: On 01/12/2023 15:38, Jeremy Kerr wrote: > Hi Quan, > >> As per [1], __i2c_transfer() will retry for adap->retries times >> consecutively (without any wait) within the amount of time specified >> by adap->timeout. >> >> So as per my observation, once it loses the arbitration, the next >> retry is most likely still lost as another controller who win the >> arbitration may still be using the bus. > > In general (and specifically with your hardware setup), the controller > should be waiting for a bus-idle state before attempting the > retransmission. You may well hit another arbitration loss after that, > but it won't be from the same bus activity. > Yes, that is the correct behaviour and I think that is why __i2c_transfer() return -EAGAIN when arbitration loss. One example I could find in kernel tree is here [a], and, it seems not to totally rely on the retry mechanism implemented in i2c core. [a] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c#n157 Anyway, it's been great to discuss on this topic. To answer your questions I did have to dig around and have learn a lot. :-) My sincere thanks to you, - Quan From fancer.lancer at gmail.com Sat Dec 2 03:25:19 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Fri, 1 Dec 2023 19:25:19 +0300 Subject: [Linux-stm32] [PATCH v1 2/2] net: stmmac: Add NPCM support In-Reply-To: <20231130213441.032a661c@device.home> References: <6aeb28f5-04c2-4723-9da2-d168025c307c@lunn.ch> <9ad42fef-b210-496a-aafc-eb2a7416c4df@lunn.ch> <25d0c091-3dce-4d62-a112-c82106809c65@lunn.ch> <20231130213441.032a661c@device.home> Message-ID: Hi Maxime On Thu, Nov 30, 2023 at 09:34:41PM +0100, Maxime Chevallier wrote: > Hello, > > On Thu, 30 Nov 2023 22:59:32 +0300 > Serge Semin wrote: > > > On Thu, Nov 30, 2023 at 06:26:13PM +0100, Andrew Lunn wrote: > > > > I will check with the xpcs maintainer how can we add indirect access > > > > to the xpcs module. > > > > > > https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c#L449 > > > > > > It creates a regmap for the memory range. On top of that it creates an > > > MDIO bus. You can then access the PCS in the normal way. > > > > Actually Synopsys DW XPCS can be synthesized with two types of the CSR > > interfaces: > > 1. MDIO: device looks as a normal MDIO device. This option is currently > > supported by the STMMAC MDIO driver. > > 2. MCI/APB3: device MMD CSRs are directly (all CSRs are visible) or > > indirectly (paged-base access) accessible over the system memory bus. > > > > In addition to the above XPCS device can be equipped with separate > > clock sources (at least to feed the MCI or APB3 interface) and may > > have dedicated IRQ line to signal various events like link > > establishing, failures, etc. From that perspective XPCS in both cases > > looks as a normal platform device for which would be better to have a > > special DT-node defined with all those resources supplied. Then the > > XPCS DT-node could be passed to the DW MAC DT-node via the already > > standardized "pcs-handle" DT-property. > > To my understanding, this should work, there's another PCS that works > this way : > https://elixir.bootlin.com/linux/v6.7-rc3/source/drivers/net/pcs/pcs-rzn1-miic.c It is similar to that, but since DW XPCS can reside on the normal MDIO bus and in the system memory I took a liberty to implement the DW XPCS MCI/APB3 interface support in the framework of the MDIO subsystem, especially seeing Synopsys call them just "Management Interfaces", the MMD CSRs can be indirectly accessible and since potentially there can be more than one XPCS device on the same MCI/APB3 bus. > > Are you still able to use the mdio-regmap glue that Andrew mentioned, > to avoid the duplication between the mdio and mmio register accesses ? Andrew cited the glue code using the Lynx PCS driver. In my case it's DW XPCS driver. In anycase my patchset is designed in a way so not to break (hopefully) the current DW XPCS driver users (STMMAC Eth for sure, WangSun XGBE, SJA1105 DSA). So it will be still possible to create a dedicated MDIO bus (using mdio-regmap API too) with the XPCS device being detectable on it. -Serge(y) > > Maxime From patrick at stwcx.xyz Sat Dec 2 05:24:45 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Fri, 1 Dec 2023 12:24:45 -0600 Subject: Suggestions required for sending the RF events in case of change happens on the backend-repos In-Reply-To: References: Message-ID: On Wed, Nov 29, 2023 at 11:33:30PM +0530, Chandramohan wrote: > H All, > > I wanted to discuss various design approaches for, sending RF events from > various OpenBMC services for resource create/delete/modify cases (but not > limited to this), > Please find the details below: I'm not fully grasping what you're trying to solve. Do you have more details on what your use-case is? Generally we _don't_ want all the repositories to know "Redfish". If what you're proposing is some special Redfish-oriented handling in every repository, I don't think this will fly. For Redfish Events, I suspect someone would need to start a dbus monitor in BMC web to observe interesting changes and to turn them into Redfish Events inside bmcweb itself. -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From william at wkennington.com Sat Dec 2 10:51:35 2023 From: william at wkennington.com (William Kennington) Date: Fri, 1 Dec 2023 15:51:35 -0800 Subject: [PATCH v2] ARM: npcm: Add CPU hotplug callbacks for kexec support In-Reply-To: <20231102101009.15104-1-william@wkennington.com> References: <20231102002453.1299195-1-william@wkennington.com> <20231102101009.15104-1-william@wkennington.com> Message-ID: On Thu, Nov 2, 2023 at 3:10?AM William A. Kennington III wrote: > > From: Brian Ma > > Add callbacks required for kexec to function. The NPCM7xx does > not expose controls for powering down CPU cores, so just wait in idle > loop. > > Signed-off-by: Brian Ma > Signed-off-by: William A. Kennington III > --- > arch/arm/mach-npcm/platsmp.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/arch/arm/mach-npcm/platsmp.c b/arch/arm/mach-npcm/platsmp.c > index 41891d3aa124..6cc7b5894f08 100644 > --- a/arch/arm/mach-npcm/platsmp.c > +++ b/arch/arm/mach-npcm/platsmp.c > @@ -69,10 +69,27 @@ static void __init npcm7xx_smp_prepare_cpus(unsigned int max_cpus) > > iounmap(scu_base); > } > +#ifdef CONFIG_HOTPLUG_CPU > +static void npcm7xx_cpu_die(unsigned int cpu) > +{ > + while (1) > + cpu_do_idle(); > +} > + > +static int npcm7xx_cpu_kill(unsigned int l_cpu) > +{ > + return 1; > +} > +#endif > + > > static struct smp_operations npcm7xx_smp_ops __initdata = { > .smp_prepare_cpus = npcm7xx_smp_prepare_cpus, > .smp_boot_secondary = npcm7xx_smp_boot_secondary, > +#ifdef CONFIG_HOTPLUG_CPU > + .cpu_die = npcm7xx_cpu_die, > + .cpu_kill = npcm7xx_cpu_kill, > +#endif > }; > > CPU_METHOD_OF_DECLARE(npcm7xx_smp, "nuvoton,npcm750-smp", &npcm7xx_smp_ops); > -- > 2.42.0.820.g83a721a137-goog >' Mind taking another look? This should be updated accordingly. From tmaimon77 at gmail.com Sun Dec 3 19:03:26 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Sun, 3 Dec 2023 10:03:26 +0200 Subject: [PATCH v2] ARM: npcm: Add CPU hotplug callbacks for kexec support In-Reply-To: References: <20231102002453.1299195-1-william@wkennington.com> <20231102101009.15104-1-william@wkennington.com> Message-ID: Hi William, On Sat, 2 Dec 2023 at 01:51, William Kennington wrote: > > On Thu, Nov 2, 2023 at 3:10?AM William A. Kennington III > wrote: > > > > From: Brian Ma > > > > Add callbacks required for kexec to function. The NPCM7xx does > > not expose controls for powering down CPU cores, so just wait in idle > > loop. > > > > Signed-off-by: Brian Ma > > Signed-off-by: William A. Kennington III > > --- > > arch/arm/mach-npcm/platsmp.c | 17 +++++++++++++++++ > > 1 file changed, 17 insertions(+) > > > > diff --git a/arch/arm/mach-npcm/platsmp.c b/arch/arm/mach-npcm/platsmp.c > > index 41891d3aa124..6cc7b5894f08 100644 > > --- a/arch/arm/mach-npcm/platsmp.c > > +++ b/arch/arm/mach-npcm/platsmp.c > > @@ -69,10 +69,27 @@ static void __init npcm7xx_smp_prepare_cpus(unsigned int max_cpus) > > > > iounmap(scu_base); > > } > > +#ifdef CONFIG_HOTPLUG_CPU > > +static void npcm7xx_cpu_die(unsigned int cpu) > > +{ > > + while (1) > > + cpu_do_idle(); > > +} > > + > > +static int npcm7xx_cpu_kill(unsigned int l_cpu) > > +{ > > + return 1; > > +} > > +#endif > > + > > > > static struct smp_operations npcm7xx_smp_ops __initdata = { > > .smp_prepare_cpus = npcm7xx_smp_prepare_cpus, > > .smp_boot_secondary = npcm7xx_smp_boot_secondary, > > +#ifdef CONFIG_HOTPLUG_CPU > > + .cpu_die = npcm7xx_cpu_die, > > + .cpu_kill = npcm7xx_cpu_kill, > > +#endif > > }; > > > > CPU_METHOD_OF_DECLARE(npcm7xx_smp, "nuvoton,npcm750-smp", &npcm7xx_smp_ops); > > -- > > 2.42.0.820.g83a721a137-goog > >' > > Mind taking another look? This should be updated accordingly. Reviewed-by: Tomer Maimon Best regards, Tomer From linux at roeck-us.net Mon Dec 4 18:04:53 2023 From: linux at roeck-us.net (Guenter Roeck) Date: Sun, 3 Dec 2023 23:04:53 -0800 Subject: [PATCH v1 0/2] hwmon: Driver for Nuvoton NCT736X In-Reply-To: <20231204055650.788388-1-kcfeng0@nuvoton.com> References: <20231204055650.788388-1-kcfeng0@nuvoton.com> Message-ID: <4d978188-b924-4f43-a619-fb5307828440@roeck-us.net> On 12/3/23 21:56, baneric926 at gmail.com wrote: > From: Ban Feng > > NCT736X is an I2C based hardware monitoring chip from Nuvoton. > No, it isn't. Such a chip does not exist. The chips are apparently NCT7362Y and NCT7363Y. No wildcards in filenames, variables, etc., please. Pick one name (nct7362y) instead and reference both chips where appropriate. Guenter From linux at roeck-us.net Mon Dec 4 18:06:37 2023 From: linux at roeck-us.net (Guenter Roeck) Date: Sun, 3 Dec 2023 23:06:37 -0800 Subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X In-Reply-To: <20231204055650.788388-3-kcfeng0@nuvoton.com> References: <20231204055650.788388-1-kcfeng0@nuvoton.com> <20231204055650.788388-3-kcfeng0@nuvoton.com> Message-ID: <87c11991-8f74-4f71-972e-373ffa1fddb1@roeck-us.net> On 12/3/23 21:56, baneric926 at gmail.com wrote: > From: Ban Feng > > NCT736X is an I2C based hardware monitoring chip from Nuvoton. > > Signed-off-by: Ban Feng > --- [ ... ] > + hwmon_dev = devm_hwmon_device_register_with_groups(dev, > + client->name, > + data, data->groups); Please resubmit using devm_hwmon_device_register_with_info(). Drivers using deprecated APIs will not be accepted. Guenter From hverkuil at xs4all.nl Tue Dec 5 01:59:02 2023 From: hverkuil at xs4all.nl (Hans Verkuil) Date: Mon, 4 Dec 2023 15:59:02 +0100 Subject: [PATCH v2 25/36] media: aspeed: Fix misuse of min_buffers_needed field In-Reply-To: <20231204132323.22811-26-benjamin.gaignard@collabora.com> References: <20231204132323.22811-1-benjamin.gaignard@collabora.com> <20231204132323.22811-26-benjamin.gaignard@collabora.com> Message-ID: On 04/12/2023 14:23, Benjamin Gaignard wrote: > 'min_buffers_needed' is suppose to be used to indicate the number > of buffers needed by DMA engine to start streaming. > aspeed doesn't use DMA engine and just want to specify > the minimum number of buffers to allocate when calling VIDIOC_REQBUFS. > That 'min_reqbufs_allocation' field purpose so use it. > > Signed-off-by: Benjamin Gaignard > Reviewed-by: Eddie James > CC: Joel Stanley (supporter:ARM/ASPEED MACHINE SUPPORT) > CC: Andrew Jeffery (reviewer:ARM/ASPEED MACHINE SUPPORT) > CC: openbmc at lists.ozlabs.org (moderated list:ASPEED VIDEO ENGINE DRIVER) > CC: linux-aspeed at lists.ozlabs.org (moderated list:ARM/ASPEED MACHINE SUPPORT) > --- > drivers/media/platform/aspeed/aspeed-video.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c > index d08aa7f73d4f..c28b10808cda 100644 > --- a/drivers/media/platform/aspeed/aspeed-video.c > +++ b/drivers/media/platform/aspeed/aspeed-video.c > @@ -2034,7 +2034,7 @@ static int aspeed_video_setup_video(struct aspeed_video *video) > vbq->drv_priv = video; > vbq->buf_struct_size = sizeof(struct aspeed_video_buffer); > vbq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; > - vbq->min_buffers_needed = ASPEED_VIDEO_V4L2_MIN_BUF_REQ; > + vbq->min_reqbufs_allocation = ASPEED_VIDEO_V4L2_MIN_BUF_REQ; Looking at the start_streaming code I think min_buffers_needed should be 1, since otherwise start_streaming would return -EPROTO. But clearly the intent is also that 3 buffers minimum are allocated. So in this case both fields should be set. Regards, Hans > > rc = vb2_queue_init(vbq); > if (rc) { From andriy.shevchenko at linux.intel.com Tue Dec 5 02:56:31 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 4 Dec 2023 17:56:31 +0200 Subject: [PATCH v1 0/5] pinctrl: Use struct pingroup and PINCTRL_PINGROUP() Message-ID: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> This is an excerpt from v4 of the "pinctrl: Convert struct group_desc to use struct pingroup" [1]. The series has been compiled with GCC 8 for ARM64 besides x86_64 GCC 13 and LLVM 16. Changelog to the mother series [1]: - added a new patch against Renesas code, so no warnings will be seen Link: https://lore.kernel.org/r/20231129161459.1002323-1-andriy.shevchenko at linux.intel.com [1] Andy Shevchenko (5): pinctrl: renesas: Mark local variable with const in ->set_mux() pinctrl: core: Make pins const unsigned int pointer in struct group_desc pinctrl: equilibrium: Convert to use struct pingroup pinctrl: keembay: Convert to use struct pingroup pinctrl: nuvoton: Convert to use struct pingroup and PINCTRL_PINGROUP() drivers/pinctrl/core.c | 2 +- drivers/pinctrl/core.h | 4 ++-- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 9 ++++---- drivers/pinctrl/pinctrl-equilibrium.c | 26 +++++++++++------------ drivers/pinctrl/pinctrl-keembay.c | 4 ++-- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +- 7 files changed, 24 insertions(+), 25 deletions(-) -- 2.43.0.rc1.1.gbec44491f096 From andriy.shevchenko at linux.intel.com Tue Dec 5 02:56:32 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 4 Dec 2023 17:56:32 +0200 Subject: [PATCH v1 1/5] pinctrl: renesas: Mark local variable with const in ->set_mux() In-Reply-To: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: <20231204160033.1872569-2-andriy.shevchenko@linux.intel.com> We are not going to change pins in the ->set_mux() callback. Mark the local variable with a const qualifier. While at it, make it also unsigned. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index aed59c53207c..68fcc2a4efbc 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -273,7 +273,7 @@ static int rzg2l_pinctrl_set_mux(struct pinctrl_dev *pctldev, struct function_desc *func; unsigned int i, *psel_val; struct group_desc *group; - int *pins; + const unsigned int *pins; func = pinmux_generic_get_function(pctldev, func_selector); if (!func) diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c index 21d7d5ac8c4a..eb304fab1796 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c +++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c @@ -165,7 +165,7 @@ static int rzv2m_pinctrl_set_mux(struct pinctrl_dev *pctldev, struct function_desc *func; unsigned int i, *psel_val; struct group_desc *group; - int *pins; + const unsigned int *pins; func = pinmux_generic_get_function(pctldev, func_selector); if (!func) -- 2.43.0.rc1.1.gbec44491f096 From andriy.shevchenko at linux.intel.com Tue Dec 5 02:56:33 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 4 Dec 2023 17:56:33 +0200 Subject: [PATCH v1 2/5] pinctrl: core: Make pins const unsigned int pointer in struct group_desc In-Reply-To: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: <20231204160033.1872569-3-andriy.shevchenko@linux.intel.com> It's unclear why it's not a const unsigned int pointer from day 1. Make the pins member const unsigned int pointer in struct group_desc. Update necessary APIs. Reviewed-by: Geert Uytterhoeven Signed-off-by: Andy Shevchenko --- drivers/pinctrl/core.c | 2 +- drivers/pinctrl/core.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 12daf0bb091e..6380e1fa6509 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -640,7 +640,7 @@ static int pinctrl_generic_group_name_to_selector(struct pinctrl_dev *pctldev, * Note that the caller must take care of locking. */ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name, - int *pins, int num_pins, void *data) + const unsigned int *pins, int num_pins, void *data) { struct group_desc *group; int selector, error; diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 8b59dd72e4ff..8ef4b536bca5 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h @@ -203,7 +203,7 @@ struct pinctrl_maps { */ struct group_desc { const char *name; - int *pins; + const unsigned int *pins; int num_pins; void *data; }; @@ -222,7 +222,7 @@ struct group_desc *pinctrl_generic_get_group(struct pinctrl_dev *pctldev, unsigned int group_selector); int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name, - int *gpins, int ngpins, void *data); + const unsigned int *pins, int num_pins, void *data); int pinctrl_generic_remove_group(struct pinctrl_dev *pctldev, unsigned int group_selector); -- 2.43.0.rc1.1.gbec44491f096 From andriy.shevchenko at linux.intel.com Tue Dec 5 02:56:34 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 4 Dec 2023 17:56:34 +0200 Subject: [PATCH v1 3/5] pinctrl: equilibrium: Convert to use struct pingroup In-Reply-To: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: <20231204160033.1872569-4-andriy.shevchenko@linux.intel.com> The pin control header provides struct pingroup. Utilize it instead of open coded variants in the driver. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-equilibrium.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c index fd59cfdeefac..4ebae516d1b1 100644 --- a/drivers/pinctrl/pinctrl-equilibrium.c +++ b/drivers/pinctrl/pinctrl-equilibrium.c @@ -705,7 +705,7 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) struct device *dev = drvdata->dev; struct device_node *node = dev->of_node; unsigned int *pins, *pinmux, pin_id, pinmux_id; - struct group_desc group; + struct pingroup group, *grp = &group; struct device_node *np; struct property *prop; int j, err; @@ -721,49 +721,49 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata) of_node_put(np); return err; } - group.num_pins = err; - group.name = prop->value; - pins = devm_kcalloc(dev, group.num_pins, sizeof(*pins), GFP_KERNEL); + grp->npins = err; + grp->name = prop->value; + pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL); if (!pins) { of_node_put(np); return -ENOMEM; } - group.pins = pins; + grp->pins = pins; - pinmux = devm_kcalloc(dev, group.num_pins, sizeof(*pinmux), GFP_KERNEL); + pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL); if (!pinmux) { of_node_put(np); return -ENOMEM; } - for (j = 0; j < group.num_pins; j++) { + for (j = 0; j < grp->npins; j++) { if (of_property_read_u32_index(np, "pins", j, &pin_id)) { dev_err(dev, "Group %s: Read intel pins id failed\n", - group.name); + grp->name); of_node_put(np); return -EINVAL; } if (pin_id >= drvdata->pctl_desc.npins) { dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n", - group.name, j, pin_id); + grp->name, j, pin_id); of_node_put(np); return -EINVAL; } pins[j] = pin_id; if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) { dev_err(dev, "Group %s: Read intel pinmux id failed\n", - group.name); + grp->name); of_node_put(np); return -EINVAL; } pinmux[j] = pinmux_id; } - err = pinctrl_generic_add_group(drvdata->pctl_dev, group.name, - group.pins, group.num_pins, + err = pinctrl_generic_add_group(drvdata->pctl_dev, + grp->name, grp->pins, grp->npins, pinmux); if (err < 0) { - dev_err(dev, "Failed to register group %s\n", group.name); + dev_err(dev, "Failed to register group %s\n", grp->name); of_node_put(np); return err; } -- 2.43.0.rc1.1.gbec44491f096 From andriy.shevchenko at linux.intel.com Tue Dec 5 02:56:35 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 4 Dec 2023 17:56:35 +0200 Subject: [PATCH v1 4/5] pinctrl: keembay: Convert to use struct pingroup In-Reply-To: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: <20231204160033.1872569-5-andriy.shevchenko@linux.intel.com> The pin control header provides struct pingroup. Utilize it instead of open coded variants in the driver. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-keembay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c index 152c35bce8ec..87d328853ae4 100644 --- a/drivers/pinctrl/pinctrl-keembay.c +++ b/drivers/pinctrl/pinctrl-keembay.c @@ -1517,7 +1517,7 @@ static int keembay_gpiochip_probe(struct keembay_pinctrl *kpc, static int keembay_build_groups(struct keembay_pinctrl *kpc) { - struct group_desc *grp; + struct pingroup *grp; unsigned int i; kpc->ngroups = kpc->npins; @@ -1528,7 +1528,7 @@ static int keembay_build_groups(struct keembay_pinctrl *kpc) /* Each pin is categorised as one group */ for (i = 0; i < kpc->ngroups; i++) { const struct pinctrl_pin_desc *pdesc = keembay_pins + i; - struct group_desc *kmb_grp = grp + i; + struct pingroup *kmb_grp = grp + i; kmb_grp->name = pdesc->name; kmb_grp->pins = (int *)&pdesc->number; -- 2.43.0.rc1.1.gbec44491f096 From andriy.shevchenko at linux.intel.com Tue Dec 5 02:56:36 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 4 Dec 2023 17:56:36 +0200 Subject: [PATCH v1 5/5] pinctrl: nuvoton: Convert to use struct pingroup and PINCTRL_PINGROUP() In-Reply-To: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: <20231204160033.1872569-6-andriy.shevchenko@linux.intel.com> The pin control header provides struct pingroup and PINCTRL_PINGROUP() macro. Utilize them instead of open coded variants in the driver. Reviewed-by: Jonathan Neusch?fer Signed-off-by: Andy Shevchenko --- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c index 0cff44b07b29..4589900244c7 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c @@ -474,9 +474,8 @@ enum { #undef WPCM450_GRP }; -static struct group_desc wpcm450_groups[] = { -#define WPCM450_GRP(x) { .name = #x, .pins = x ## _pins, \ - .num_pins = ARRAY_SIZE(x ## _pins) } +static struct pingroup wpcm450_groups[] = { +#define WPCM450_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins)) WPCM450_GRPS #undef WPCM450_GRP }; @@ -852,7 +851,7 @@ static int wpcm450_get_group_pins(struct pinctrl_dev *pctldev, const unsigned int **pins, unsigned int *npins) { - *npins = wpcm450_groups[selector].num_pins; + *npins = wpcm450_groups[selector].npins; *pins = wpcm450_groups[selector].pins; return 0; @@ -901,7 +900,7 @@ static int wpcm450_pinmux_set_mux(struct pinctrl_dev *pctldev, struct wpcm450_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); wpcm450_setfunc(pctrl->gcr_regmap, wpcm450_groups[group].pins, - wpcm450_groups[group].num_pins, function); + wpcm450_groups[group].npins, function); return 0; } -- 2.43.0.rc1.1.gbec44491f096 From geert at linux-m68k.org Tue Dec 5 03:18:49 2023 From: geert at linux-m68k.org (Geert Uytterhoeven) Date: Mon, 4 Dec 2023 17:18:49 +0100 Subject: [PATCH v1 1/5] pinctrl: renesas: Mark local variable with const in ->set_mux() In-Reply-To: <20231204160033.1872569-2-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> <20231204160033.1872569-2-andriy.shevchenko@linux.intel.com> Message-ID: On Mon, Dec 4, 2023 at 5:02?PM Andy Shevchenko wrote: > We are not going to change pins in the ->set_mux() callback. Mark > the local variable with a const qualifier. While at it, make it > also unsigned. > > Signed-off-by: Andy Shevchenko Reviewed-by: Geert Uytterhoeven Acked-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds From fancer.lancer at gmail.com Tue Dec 5 21:35:21 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:21 +0300 Subject: [PATCH net-next 00/16] net: pcs: xpcs: Add memory-based management iface support Message-ID: <20231205103559.9605-1-fancer.lancer@gmail.com> The main goal of this series is to extend the DW XPCS device support in the kernel. Particularly the patchset adds the DW XPCS MCI/APB3 management interface support to the MDIO subsystem (basically it's a way to access the memory-mapped DW XPCS devices), modifies the DW XPCS PCS-driver to being registered as a standard MDIO-device driver and finally extends the STMMAC MDIO sub-module functionality so one would be able to support both SMA- and MI-based ways to communicate with the XPCS-device. The later way will implies to have an XPCS-device passed to the DW MAC node via the generic "pcs-handle" property. The series traditionally starts with the cleanup patches, which can be also considered as preparations. First redundant sentinel entry and the header files are removed. Then two errno cleanups are introduced: return EINVAL from the soft-reset method and make sure that the validate method returns EINVAL straight away if the requested interface isn't supported by the XPCS device instance. Afterwards three preparation patches are introduced. First one just moves the generic DW XPCS IDs macro-based declarations from the internal header file to the external one where some other IDs also reside. Second patch updates the XPCS registration procedure to avoid dummy MDIO-device creation if it is already available in the framework of the specified MDIO-bus. Finally third patch splits up the xpcs_create() method to a set of the coherent sub-function for the sake of the further easier updates and to have it looking less complicated. The next three patches add the DW XPCS Management Interface driver to the MDIO subsystem, update the DW XPCS driver to support a PCS-device registered on a MDIO-bus and add the DT-bindings for both of these objects. Note the hierarchical design (having a DW XPCS device defined as a sub-node of the DW XPCS management interface node) has been chosen for several reasons. First Synopsys calls the MCI/APB3 interface as Management Interface with two possible ways of the MMD CSRs access (direct and indirect), which is basically a bus between the system and the PCS-device with a possibility to have more than just one device attached. So the chosen design looks more correct from the HW representation point of view. Second the drivers for the SMA/MDIO-capable controllers (STMMAC and it's glue layers for example) will still be able to manually register an MDIO-bus but from now with custom XPCS-device identifiers. So the DW XPCS driver will get to be attached to that device activating respective internal functionality (see patches 10, 13 and 16). Thus if there is no way to auto-identify the XPCS device capabilities it can be done based on the custom device IDs or DT-node compatible string (see patch 10). But if it's, then the device IDs will be auto-detected by the MDIO-subsystem and the DW XPCS driver will still get attached to the device on the MDIO-bus. All of that AFAICS would have been impossible (or much harder) to implement should the Management Interface MDIO-bus be just internally created in the DW XPCS driver. Afterwards two patches add the "pcs-handle" DT-property support to the DW XPCS driver. The first one of them is a preparation patch, which just converts the name of the currently available XPCS device registration method to having "_byaddr" suffix. It better identifies the method and will make it more distinguishable from the method being added in the next patch. The second patch introduces a new function which responsibility is to create the DW XPCS descriptor based on the "pcs-handle" property and PCS-PHY interface. The prototype is specifically selected to be looking similar to another XPCS device registration method and to the phylink fwnode-based connect interface function. Finally after two small preparations the STMMAC driver is finally updated to support the DW XPCS devices specified via the "pcs-handle" firmware node. Thus the STMMAC driver from now will be able to handle the cases with the DW XPCS devices accessible over the memory-based management interface or over the external MDIO-buses. That's it for now. Thanks for review in advance. Any tests are very welcome. After this series is merged in, I'll submit another one which adds the generic 10GBase-R and 10GBase-X interfaces support to the STMMAC and DW XPCS driver with proper CSRs re-initialization, PMA initialization and reference clock selection as it's defined by the Synopsys DW XPCS HW manual. Signed-off-by: Serge Semin Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Alexandre Torgue Cc: openbmc at lists.ozlabs.org Cc: netdev at vger.kernel.org Cc: devicetree at vger.kernel.org Cc: linux-kernel at vger.kernel.org Serge Semin (16): net: pcs: xpcs: Drop sentinel entry from 2500basex ifaces list net: pcs: xpcs: Drop redundant workqueue.h include directive net: pcs: xpcs: Return EINVAL in the internal methods net: pcs: xpcs: Explicitly return error on caps validation net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h net: pcs: xpcs: Avoid creating dummy XPCS MDIO device net: pcs: xpcs: Split up xpcs_create() content to sub-functions dt-bindings: net: Add Synopsys DW xPCS bindings net: mdio: Add Synopsys DW XPCS management interface support net: pcs: xpcs: Add generic DW XPCS MDIO-device support net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" net: pcs: xpcs: Add xpcs_create_bynode() method net: stmmac: intel: Register generic MDIO device net: stmmac: Pass netdev to XPCS setup function net: stmmac: Add dedicated XPCS cleanup method net: stmmac: Add externally detected DW XPCS support .../bindings/net/pcs/snps,dw-xpcs.yaml | 88 ++++ .../bindings/net/snps,dw-xpcs-mi.yaml | 88 ++++ drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 31 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 51 ++- drivers/net/mdio/Kconfig | 8 + drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-dw-xpcs.c | 384 ++++++++++++++++++ drivers/net/pcs/Kconfig | 6 +- drivers/net/pcs/pcs-xpcs.c | 285 ++++++++++--- drivers/net/pcs/pcs-xpcs.h | 7 +- include/linux/pcs/pcs-xpcs.h | 36 +- 14 files changed, 908 insertions(+), 96 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml create mode 100644 Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml create mode 100644 drivers/net/mdio/mdio-dw-xpcs.c -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:23 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:23 +0300 Subject: [PATCH net-next 02/16] net: pcs: xpcs: Drop redundant workqueue.h include directive In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-3-fancer.lancer@gmail.com> There is nothing CM workqueue-related in the driver. So the respective include directive can be dropped. While at it add an empty line delimiter between the generic and local path include directives. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index dc7c374da495..7f8c63922a4b 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -10,7 +10,7 @@ #include #include #include -#include + #include "pcs-xpcs.h" #define phylink_pcs_to_xpcs(pl_pcs) \ -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:24 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:24 +0300 Subject: [PATCH net-next 03/16] net: pcs: xpcs: Return EINVAL in the internal methods In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-4-fancer.lancer@gmail.com> In particular the xpcs_soft_reset() and xpcs_do_config() functions currently return -1 if invalid auto-negotiation mode is specified. That value can be then passed to the generic kernel subsystems which require a standard kernel errno value. Even though the error conditions are very specific (memory corruption or buggy implementation) using a hard-coded -1 literal doesn't seem correct anyway. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 7f8c63922a4b..92c47da61db4 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -292,7 +292,7 @@ static int xpcs_soft_reset(struct dw_xpcs *xpcs, dev = MDIO_MMD_VEND2; break; default: - return -1; + return -EINVAL; } ret = xpcs_write(xpcs, dev, MDIO_CTRL1, MDIO_CTRL1_RESET); @@ -889,7 +889,7 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, return ret; break; default: - return -1; + return -EINVAL; } if (compat->pma_config) { -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:25 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:25 +0300 Subject: [PATCH net-next 04/16] net: pcs: xpcs: Explicitly return error on caps validation In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-5-fancer.lancer@gmail.com> If an unsupported interface is requested to be validated then there is no need in further capabilities and-ing since the local array will be left initialized with zeros. Let's explicitly return EINVAL error in that case in order to inform the caller about invalid link-state interface. In any case the phylink_validate_mac_and_pcs() would terminate with error further link-state validation so the suggested update won't change the validation procedure semantics. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 92c47da61db4..46afeb5510c0 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -613,14 +613,15 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported, xpcs = phylink_pcs_to_xpcs(pcs); compat = xpcs_find_compat(xpcs->id, state->interface); + if (!compat) + return -EINVAL; /* Populate the supported link modes for this PHY interface type. * FIXME: what about the port modes and autoneg bit? This masks * all those away. */ - if (compat) - for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) - set_bit(compat->supported[i], xpcs_supported); + for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + set_bit(compat->supported[i], xpcs_supported); linkmode_and(supported, supported, xpcs_supported); -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:22 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:22 +0300 Subject: [PATCH net-next 01/16] net: pcs: xpcs: Drop sentinel entry from 2500basex ifaces list In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-2-fancer.lancer@gmail.com> There are currently two methods (xpcs_find_compat() and xpcs_get_interfaces()) defined in the driver which loop over the available interfaces. All of them rely on the xpcs_compat.num_interfaces field value to get the number of interfaces. That field is initialized with the ARRAY_SIZE(xpcs_*_interfaces) macro function call. Thus the interface arrays are supposed to be filled with actual interface IDs and there is no need in the dummy terminating ID placed at the end of the arrays. Let's drop the redundant PHY_INTERFACE_MODE_MAX entry from the xpcs_2500basex_interfaces list and the redundant PHY_INTERFACE_MODE_MAX-based conditional statement from the xpcs_get_interfaces() method then. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 31f0beba638a..dc7c374da495 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -130,7 +130,6 @@ static const phy_interface_t xpcs_1000basex_interfaces[] = { static const phy_interface_t xpcs_2500basex_interfaces[] = { PHY_INTERFACE_MODE_2500BASEX, - PHY_INTERFACE_MODE_MAX, }; enum { @@ -636,8 +635,7 @@ void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces) const struct xpcs_compat *compat = &xpcs->id->compat[i]; for (j = 0; j < compat->num_interfaces; j++) - if (compat->interface[j] < PHY_INTERFACE_MODE_MAX) - __set_bit(compat->interface[j], interfaces); + __set_bit(compat->interface[j], interfaces); } } EXPORT_SYMBOL_GPL(xpcs_get_interfaces); -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:26 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:26 +0300 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-6-fancer.lancer@gmail.com> Generic MDIO-device driver will support setting a custom device ID for the particular MDIO-device. Generic DW XPCS ID can be used for that as well just in case if the DW XPCS-device was erroneously synthesized with no or some undefined ID. In addition to that having all supported DW XPCS device IDs defined in a sinle place will improve the code maintainability and readability. Note while at it rename the macros to be shorter and looking alike to the already defined NXP XPCS ID macro. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 8 ++++---- drivers/net/pcs/pcs-xpcs.h | 3 --- include/linux/pcs/pcs-xpcs.h | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 46afeb5510c0..2850122f354a 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1343,16 +1343,16 @@ static const struct xpcs_compat nxp_sja1110_xpcs_compat[DW_XPCS_INTERFACE_MAX] = static const struct xpcs_id xpcs_id_list[] = { { - .id = SYNOPSYS_XPCS_ID, - .mask = SYNOPSYS_XPCS_MASK, + .id = DW_XPCS_ID, + .mask = DW_XPCS_ID_MASK, .compat = synopsys_xpcs_compat, }, { .id = NXP_SJA1105_XPCS_ID, - .mask = SYNOPSYS_XPCS_MASK, + .mask = DW_XPCS_ID_MASK, .compat = nxp_sja1105_xpcs_compat, }, { .id = NXP_SJA1110_XPCS_ID, - .mask = SYNOPSYS_XPCS_MASK, + .mask = DW_XPCS_ID_MASK, .compat = nxp_sja1110_xpcs_compat, }, }; diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h index 96c36b32ca99..369e9196f45a 100644 --- a/drivers/net/pcs/pcs-xpcs.h +++ b/drivers/net/pcs/pcs-xpcs.h @@ -6,9 +6,6 @@ * Author: Jose Abreu */ -#define SYNOPSYS_XPCS_ID 0x7996ced0 -#define SYNOPSYS_XPCS_MASK 0xffffffff - /* Vendor regs access */ #define DW_VENDOR BIT(15) diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index da3a6c30f6d2..8dfe90295f12 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -12,6 +12,8 @@ #define NXP_SJA1105_XPCS_ID 0x00000010 #define NXP_SJA1110_XPCS_ID 0x00000020 +#define DW_XPCS_ID 0x7996ced0 +#define DW_XPCS_ID_MASK 0xffffffff /* AN mode */ #define DW_AN_C73 1 -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:27 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:27 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-7-fancer.lancer@gmail.com> If the DW XPCS MDIO devices are either left unmasked for being auto-probed or explicitly registered in the MDIO subsystem by means of the mdiobus_register_board_info() method there is no point in creating the dummy MDIO device instance in order to get the DW XPCS handler since the MDIO core subsystem will create the device during the MDIO bus registration procedure. All what needs to be done is to just reuse the MDIO-device instance available in the mii_bus.mdio_map array (using some getter for it would look better though). It shall prevent the XPCS devices been accessed over several MDIO-device instances. Note since the MDIO-device instance might be retrieved from the MDIO-bus map array its reference counter shall be increased. If the MDIO-device instance is created in the xpcs_create_mdiodev() method its reference counter will be already increased. So there is no point in toggling the reference counter in the xpcs_create() function. Just drop it from there. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 2850122f354a..a53376472394 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1376,7 +1376,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, if (!xpcs) return ERR_PTR(-ENOMEM); - mdio_device_get(mdiodev); xpcs->mdiodev = mdiodev; xpcs_id = xpcs_get_id(xpcs); @@ -1417,7 +1416,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, ret = -ENODEV; out: - mdio_device_put(mdiodev); kfree(xpcs); return ERR_PTR(ret); @@ -1437,19 +1435,21 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, struct mdio_device *mdiodev; struct dw_xpcs *xpcs; - mdiodev = mdio_device_create(bus, addr); - if (IS_ERR(mdiodev)) - return ERR_CAST(mdiodev); + if (addr >= PHY_MAX_ADDR) + return ERR_PTR(-EINVAL); - xpcs = xpcs_create(mdiodev, interface); + if (mdiobus_is_registered_device(bus, addr)) { + mdiodev = bus->mdio_map[addr]; + mdio_device_get(mdiodev); + } else { + mdiodev = mdio_device_create(bus, addr); + if (IS_ERR(mdiodev)) + return ERR_CAST(mdiodev); + } - /* xpcs_create() has taken a refcount on the mdiodev if it was - * successful. If xpcs_create() fails, this will free the mdio - * device here. In any case, we don't need to hold our reference - * anymore, and putting it here will allow mdio_device_put() in - * xpcs_destroy() to automatically free the mdio device. - */ - mdio_device_put(mdiodev); + xpcs = xpcs_create(mdiodev, interface); + if (IS_ERR(xpcs)) + mdio_device_put(mdiodev); return xpcs; } -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:28 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:28 +0300 Subject: [PATCH net-next 07/16] net: pcs: xpcs: Split up xpcs_create() content to sub-functions In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-8-fancer.lancer@gmail.com> As a final preparation before adding the DW XPCS MDIO-device driver support let's split the xpcs_create() function code up to a set of small sub-functions. Thus the method implementation will get to look simpler and turn to be more coherent. Further updates will just touch the new methods a bit: add platform-specific device info, add device reference clock getting and enabling. This update implies the xpcs_create() to call the next static methods: xpcs_create_data() - create the DW XPCS device descriptor, xpcs_init_id() - find XPCS ID instance and save it in the device descriptor, xpcs_init_iface() - find MAC/PCS interface descriptor and perform basice initialization specific to it: soft-reset, disable polling. The update doesn't cause any semantic change but merely makes the code better looking and ready for adding new features support. Note in addition to that the xpcs_destroy() is moved to be below the xpcs_create_mdiodev() function as the driver now implies having the protagonist-then-antagonist functions definition order. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 102 +++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index a53376472394..ea6f56339595 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1365,70 +1365,97 @@ static const struct phylink_pcs_ops xpcs_phylink_ops = { .pcs_link_up = xpcs_link_up, }; -static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, - phy_interface_t interface) +static struct dw_xpcs *xpcs_create_data(struct mdio_device *mdiodev) { struct dw_xpcs *xpcs; - u32 xpcs_id; - int i, ret; xpcs = kzalloc(sizeof(*xpcs), GFP_KERNEL); if (!xpcs) return ERR_PTR(-ENOMEM); xpcs->mdiodev = mdiodev; + xpcs->pcs.ops = &xpcs_phylink_ops; + xpcs->pcs.neg_mode = true; + xpcs->pcs.poll = true; + + return xpcs; +} + +static void xpcs_free_data(struct dw_xpcs *xpcs) +{ + kfree(xpcs); +} + +static int xpcs_init_id(struct dw_xpcs *xpcs) +{ + u32 xpcs_id; + int i, ret; xpcs_id = xpcs_get_id(xpcs); for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { const struct xpcs_id *entry = &xpcs_id_list[i]; - const struct xpcs_compat *compat; if ((xpcs_id & entry->mask) != entry->id) continue; xpcs->id = entry; - compat = xpcs_find_compat(entry, interface); - if (!compat) { - ret = -ENODEV; - goto out; - } + break; + } - ret = xpcs_dev_flag(xpcs); - if (ret) - goto out; + if (!xpcs->id) + return -ENODEV; - xpcs->pcs.ops = &xpcs_phylink_ops; - xpcs->pcs.neg_mode = true; + ret = xpcs_dev_flag(xpcs); + if (ret < 0) + return ret; - if (xpcs->dev_flag != DW_DEV_TXGBE) { - xpcs->pcs.poll = true; + return 0; +} - ret = xpcs_soft_reset(xpcs, compat); - if (ret) - goto out; - } +static int xpcs_init_iface(struct dw_xpcs *xpcs, phy_interface_t interface) +{ + const struct xpcs_compat *compat; - return xpcs; + compat = xpcs_find_compat(xpcs->id, interface); + if (!compat) + return -EINVAL; + + if (xpcs->dev_flag == DW_DEV_TXGBE) { + xpcs->pcs.poll = false; + return 0; } - ret = -ENODEV; + return xpcs_soft_reset(xpcs, compat); +} + +static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, + phy_interface_t interface) +{ + struct dw_xpcs *xpcs; + int ret; + + xpcs = xpcs_create_data(mdiodev); + if (IS_ERR(xpcs)) + return xpcs; + + ret = xpcs_init_id(xpcs); + if (ret) + goto out; + + ret = xpcs_init_iface(xpcs, interface); + if (ret) + goto out; + + return xpcs; out: - kfree(xpcs); + xpcs_free_data(xpcs); return ERR_PTR(ret); } -void xpcs_destroy(struct dw_xpcs *xpcs) -{ - if (xpcs) - mdio_device_put(xpcs->mdiodev); - kfree(xpcs); -} -EXPORT_SYMBOL_GPL(xpcs_destroy); - struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, phy_interface_t interface) { @@ -1455,4 +1482,15 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, } EXPORT_SYMBOL_GPL(xpcs_create_mdiodev); +void xpcs_destroy(struct dw_xpcs *xpcs) +{ + if (!xpcs) + return; + + mdio_device_put(xpcs->mdiodev); + + xpcs_free_data(xpcs); +} +EXPORT_SYMBOL_GPL(xpcs_destroy); + MODULE_LICENSE("GPL v2"); -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:29 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:29 +0300 Subject: [PATCH net-next 08/16] dt-bindings: net: Add Synopsys DW xPCS bindings In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-9-fancer.lancer@gmail.com> Synopsys DesignWare XPCS IP-core is a Physical Coding Sublayer (PCS) layer providing an interface between the Media Access Control (MAC) and Physical Medium Attachment Sublayer (PMA) through a Media independent interface. >From software point of view it exposes IEEE std. Clause 45 CSR space and can be accessible either by MDIO or MCI/APB3 bus interfaces. The later case is described by means of a dedicated DT-bindings which imply having the DW XPCS Management Interface defined as a DT-supernode which child the PCSs nodes would be (in the same way as the standard MDIO buses and devices are normally defined). Besides of that DW XPCS DT-nodes can have the interrupts and clock source properties specified. The former one indicates the Clause 73/37 auto-negotiation events like: negotiation page received, AN is completed or incompatible link partner. The clock DT-properties can describe up to two clock sources: internal one and the one connected to the chip pad. Either of them is supposed to be used as the device reference clocks. Finally the DW XPCS IP-core can be optionally synthesized with a vendor-specific interface connected to Synopsys PMA (also called DesignWare Consumer/Enterprise PHY). Alas that isn't auto-detectable anyhow so if the DW XPCS device has the respective PMA attached then it should be reflected in the DT-node compatible string so the driver would be aware of the PMA-specific device capabilities (mainly connected with CSRs available for the fine-tunings). Signed-off-by: Serge Semin --- .../bindings/net/pcs/snps,dw-xpcs.yaml | 88 +++++++++++++++++++ .../bindings/net/snps,dw-xpcs-mi.yaml | 88 +++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml create mode 100644 Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml diff --git a/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml new file mode 100644 index 000000000000..9694ef51abad --- /dev/null +++ b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/pcs/snps,dw-xpcs.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare Ethernet PCS + +maintainers: + - Jose Abreu + +description: + Synopsys DesignWare Ethernet Physical Coding Sublayer provides an interface + between Media Access Control and Physical Medium Attachment Sublayer through + the Media Independent Interface (XGMII, USXGMII, XLGMII, GMII, etc) + controlled by means of the IEEE std. Clause 45 registers set. The PCS can be + optionally synthesized with a vendor-specific interface connected to + Synopsys PMA (also called DesignWare Consumer/Enterprise PHY) although in + general it can be used to communicate with any compatible PHY. + +properties: + compatible: + oneOf: + - description: Synopsys DesignWare XPCS with none or unknown PMA + const: snps,dw-xpcs + - description: Synopsys DesignWare XPCS with Consumer Gen1 3G PMA + const: snps,dw-xpcs-gen1-3g + - description: Synopsys DesignWare XPCS with Consumer Gen2 3G PMA + const: snps,dw-xpcs-gen2-3g + - description: Synopsys DesignWare XPCS with Consumer Gen2 6G PMA + const: snps,dw-xpcs-gen2-6g + - description: Synopsys DesignWare XPCS with Consumer Gen4 3G PMA + const: snps,dw-xpcs-gen4-3g + - description: Synopsys DesignWare XPCS with Consumer Gen4 6G PMA + const: snps,dw-xpcs-gen4-6g + - description: Synopsys DesignWare XPCS with Consumer Gen5 10G PMA + const: snps,dw-xpcs-gen5-10g + - description: Synopsys DesignWare XPCS with Consumer Gen5 12G PMA + const: snps,dw-xpcs-gen5-12g + + reg: + maxItems: 1 + + interrupts: + description: + System interface interrupt output (sbd_intr_o) indicating Clause 73/37 + auto-negotiation events like':' Page received, AN is completed or + incompatible link partner. + maxItems: 1 + + clocks: + description: + PCS/PMA interface be can clocked either by internal reference clock + source or by an externally connected (via a pad) clock generator. + minItems: 1 + maxItems: 2 + + clock-names: + minItems: 1 + maxItems: 2 + items: + enum: [ core, pad ] + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + + mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + + xgmac_pcs: ethernet-pcs at 0 { + compatible = "snps,dw-xpcs"; + reg = <0>; + + interrupts = <79 IRQ_TYPE_LEVEL_HIGH>; + + clocks = <&ccu_core>, <&ccu_pad>; + clock-names = "core", "pad"; + }; + }; +... diff --git a/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml new file mode 100644 index 000000000000..67ddba9d61fd --- /dev/null +++ b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml @@ -0,0 +1,88 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/snps,dw-xpcs-mi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Synopsys DesignWare Ethernet PCS Management Interface + +maintainers: + - Serge Semin + +description: + Synopsys DesignWare Ethernet PCS provides an interface between MAC and PMA + through the Media Independent Interface. The PCS CSRs can be accessible over + the Ethernet MDIO bus or directly by means of the APB3/MCI interfaces. In the + later case the XPCS can be mapped right to the system IO memory space. + +allOf: + - $ref: mdio.yaml# + +properties: + compatible: + const: snps,dw-xpcs-mi + + reg: + items: + - description: + DW XPCS CSRs space can be either 'directly' or 'indirectly' + accessible. In the former case all Clause 45 registers are + contiguously mapped within the address space MMD '[20:16]', + Reg '[15:0]'. In the later case the space is divided to the + multiple 256 register sets. There is a special viewport CSR + which is responsible for the set selection. The upper part of + the CSR address is supposed to be written in there thus the + corresponding subset would be mapped over the lowest 255 CSRs. + + reg-names: + items: + - enum: [ direct, indirect ] + + reg-io-width: + description: + The way the CSRs are mapped to the memory is platform depended. Since + each Clause 45 CSR is of 16-bits wide the access instructions must be + two bytes aligned at least. + default: 2 + enum: [ 2, 4 ] + + clocks: + items: + - description: Peripheral MCI/APB3 bus clock source + + clock-names: + items: + - const: pclk + +patternProperties: + 'ethernet-pcs@[0-9a-f]+$': + type: object + + $ref: pcs/snps,dw-xpcs.yaml# + +required: + - compatible + - reg + - reg-names + +unevaluatedProperties: false + +examples: + - | + mdio at 1f05d000 { + compatible = "snps,dw-xpcs-mi"; + reg = <0x1f05d000 0x1000>; + reg-names = "indirect"; + #address-cells = <1>; + #size-cells = <0>; + + clocks = <&ccu_pclk>; + clock-names = "pclk"; + + reg-io-width = <4>; + + ethernet-pcs at 0 { + compatible = "snps,dw-xpcs"; + reg = <0>; + }; + }; -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:30 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:30 +0300 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-10-fancer.lancer@gmail.com> Synopsys DesignWare XPCS IP-core can be synthesized with the device CSRs being accessible over MCI or APB3 interface instead of the MDIO bus (see the CSR_INTERFACE HDL parameter). Thus all the PCS registers can be just memory mapped and be a subject of standard MMIO operations of course taking into account the way the Clause C45 CSRs mapping is defined. This commit is about adding a device driver for the DW XPCS Management Interface platform device and registering it in the framework of the kernel MDIO subsystem. DW XPCS platform device is supposed to be described by the respective compatible string "snps,dw-xpcs-mi", CSRs memory space and optional peripheral bus clock source. Note depending on the INDIRECT_ACCESS DW XPCS IP-core synthesize parameter the memory-mapped reg-space can be represented as either directly or indirectly mapped Clause 45 space. In the former case the particular address is determined based on the MMD device and the registers offset (5 + 16 bits all together) within the device reg-space. In the later case there is only 256 lower address bits are utilized for the registers mapping. The upper bits are supposed to be written into the respective viewport CSR in order to reach the entire C45 space. Signed-off-by: Serge Semin --- drivers/net/mdio/Kconfig | 8 + drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-dw-xpcs.c | 384 ++++++++++++++++++++++++++++++++ 3 files changed, 393 insertions(+) create mode 100644 drivers/net/mdio/mdio-dw-xpcs.c diff --git a/drivers/net/mdio/Kconfig b/drivers/net/mdio/Kconfig index 4a7a303be2f7..39f7ce8087bf 100644 --- a/drivers/net/mdio/Kconfig +++ b/drivers/net/mdio/Kconfig @@ -185,6 +185,14 @@ config MDIO_IPQ8064 This driver supports the MDIO interface found in the network interface units of the IPQ8064 SoC +config MDIO_DW_XPCS + tristate "Synopsys DesignWare XPCS MI bus support" + depends on HAS_IOMEM + select MDIO_DEVRES + help + This driver supports the MCI/APB3 Management Interface responsible + for communicating with the Synopsys DesignWare XPCS devices. + config MDIO_REGMAP tristate help diff --git a/drivers/net/mdio/Makefile b/drivers/net/mdio/Makefile index 1015f0db4531..6389d4c3b862 100644 --- a/drivers/net/mdio/Makefile +++ b/drivers/net/mdio/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o obj-$(CONFIG_MDIO_CAVIUM) += mdio-cavium.o +obj-$(CONFIG_MDIO_DW_XPCS) += mdio-dw-xpcs.o obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o obj-$(CONFIG_MDIO_HISI_FEMAC) += mdio-hisi-femac.o obj-$(CONFIG_MDIO_I2C) += mdio-i2c.o diff --git a/drivers/net/mdio/mdio-dw-xpcs.c b/drivers/net/mdio/mdio-dw-xpcs.c new file mode 100644 index 000000000000..c47f0a54d31b --- /dev/null +++ b/drivers/net/mdio/mdio-dw-xpcs.c @@ -0,0 +1,384 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Synopsys DesignWare XPCS Management Interface driver + * + * Copyright (C) 2023 BAIKAL ELECTRONICS, JSC + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Page select register for the indirect MMIO CSRs access */ +#define DW_VR_CSR_VIEWPORT 0xff + +struct dw_xpcs_mi { + struct platform_device *pdev; + struct mii_bus *bus; + bool reg_indir; + int reg_width; + void __iomem *reg_base; + struct clk *pclk; +}; + +static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) +{ + return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); +} + +static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) +{ + return FIELD_GET(0x1fff00, csr); +} + +static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) +{ + return FIELD_GET(0xff, csr); +} + +static int dw_xpcs_mmio_read_reg_indirect(struct dw_xpcs_mi *dxmi, + int dev, int reg) +{ + ptrdiff_t csr, ofs; + u16 page; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + page = dw_xpcs_mmio_addr_page(csr); + ofs = dw_xpcs_mmio_addr_offset(csr); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + writel(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 2)); + ret = readl(dxmi->reg_base + (ofs << 2)); + break; + default: + writew(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 1)); + ret = readw(dxmi->reg_base + (ofs << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return ret; +} + +static int dw_xpcs_mmio_write_reg_indirect(struct dw_xpcs_mi *dxmi, + int dev, int reg, u16 val) +{ + ptrdiff_t csr, ofs; + u16 page; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + page = dw_xpcs_mmio_addr_page(csr); + ofs = dw_xpcs_mmio_addr_offset(csr); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + writel(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 2)); + writel(val, dxmi->reg_base + (ofs << 2)); + break; + default: + writew(page, dxmi->reg_base + (DW_VR_CSR_VIEWPORT << 1)); + writew(val, dxmi->reg_base + (ofs << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return 0; +} + +static int dw_xpcs_mmio_read_reg_direct(struct dw_xpcs_mi *dxmi, + int dev, int reg) +{ + ptrdiff_t csr; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + ret = readl(dxmi->reg_base + (csr << 2)); + break; + default: + ret = readw(dxmi->reg_base + (csr << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return ret; +} + +static int dw_xpcs_mmio_write_reg_direct(struct dw_xpcs_mi *dxmi, + int dev, int reg, u16 val) +{ + ptrdiff_t csr; + int ret; + + csr = dw_xpcs_mmio_addr_format(dev, reg); + + ret = pm_runtime_resume_and_get(&dxmi->pdev->dev); + if (ret) + return ret; + + switch (dxmi->reg_width) { + case 4: + writel(val, dxmi->reg_base + (csr << 2)); + break; + default: + writew(val, dxmi->reg_base + (csr << 1)); + break; + } + + pm_runtime_put(&dxmi->pdev->dev); + + return 0; +} + +static int dw_xpcs_mmio_read_c22(struct mii_bus *bus, int addr, int reg) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_read_reg_indirect(dxmi, MDIO_MMD_VEND2, reg); + else + return dw_xpcs_mmio_read_reg_direct(dxmi, MDIO_MMD_VEND2, reg); +} + +static int dw_xpcs_mmio_write_c22(struct mii_bus *bus, int addr, int reg, u16 val) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_write_reg_indirect(dxmi, MDIO_MMD_VEND2, reg, val); + else + return dw_xpcs_mmio_write_reg_direct(dxmi, MDIO_MMD_VEND2, reg, val); +} + +static int dw_xpcs_mmio_read_c45(struct mii_bus *bus, int addr, int dev, int reg) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_read_reg_indirect(dxmi, dev, reg); + else + return dw_xpcs_mmio_read_reg_direct(dxmi, dev, reg); +} + +static int dw_xpcs_mmio_write_c45(struct mii_bus *bus, int addr, int dev, + int reg, u16 val) +{ + struct dw_xpcs_mi *dxmi = bus->priv; + + if (addr != 0) + return -ENODEV; + + if (dxmi->reg_indir) + return dw_xpcs_mmio_write_reg_indirect(dxmi, dev, reg, val); + else + return dw_xpcs_mmio_write_reg_direct(dxmi, dev, reg, val); +} + +static struct dw_xpcs_mi *dw_xpcs_mi_create_data(struct platform_device *pdev) +{ + struct dw_xpcs_mi *dxmi; + + dxmi = devm_kzalloc(&pdev->dev, sizeof(*dxmi), GFP_KERNEL); + if (!dxmi) + return ERR_PTR(-ENOMEM); + + dxmi->pdev = pdev; + + dev_set_drvdata(&pdev->dev, dxmi); + + return dxmi; +} + +static int dw_xpcs_mi_init_res(struct dw_xpcs_mi *dxmi) +{ + struct device *dev = &dxmi->pdev->dev; + struct resource *res; + + if (!device_property_read_u32(dev, "reg-io-width", &dxmi->reg_width)) { + if (dxmi->reg_width != 2 && dxmi->reg_width != 4) { + dev_err(dev, "Invalid regspace data width\n"); + return -EINVAL; + } + } else { + dxmi->reg_width = 2; + } + + res = platform_get_resource_byname(dxmi->pdev, IORESOURCE_MEM, "direct") ?: + platform_get_resource_byname(dxmi->pdev, IORESOURCE_MEM, "indirect"); + if (!res) { + dev_err(dev, "No regspace found\n"); + return -EINVAL; + } + + if (!strcmp(res->name, "indirect")) + dxmi->reg_indir = true; + + if ((dxmi->reg_indir && resource_size(res) < dxmi->reg_width * SZ_256) || + (!dxmi->reg_indir && resource_size(res) < dxmi->reg_width * SZ_2M)) { + dev_err(dev, "Invalid regspace size\n"); + return -EINVAL; + } + + dxmi->reg_base = devm_ioremap_resource(dev, res); + if (IS_ERR(dxmi->reg_base)) { + dev_err(dev, "Failed to map regspace\n"); + return PTR_ERR(dxmi->reg_base); + } + + return 0; +} + +static int dw_xpcs_mi_init_clk(struct dw_xpcs_mi *dxmi) +{ + struct device *dev = &dxmi->pdev->dev; + int ret; + + dxmi->pclk = devm_clk_get_optional(dev, "pclk"); + if (IS_ERR(dxmi->pclk)) + return dev_err_probe(dev, PTR_ERR(dxmi->pclk), + "Failed to get ref clock\n"); + + pm_runtime_set_active(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) { + dev_err(dev, "Failed to enable runtime-PM\n"); + return ret; + } + + return 0; +} + +static int dw_xpcs_mi_init_mdio(struct dw_xpcs_mi *dxmi) +{ + struct device *dev = &dxmi->pdev->dev; + static atomic_t id = ATOMIC_INIT(-1); + int ret; + + dxmi->bus = devm_mdiobus_alloc_size(dev, 0); + if (!dxmi->bus) + return -ENOMEM; + + dxmi->bus->name = "DW XPCS MI"; + dxmi->bus->read = dw_xpcs_mmio_read_c22; + dxmi->bus->write = dw_xpcs_mmio_write_c22; + dxmi->bus->read_c45 = dw_xpcs_mmio_read_c45; + dxmi->bus->write_c45 = dw_xpcs_mmio_write_c45; + dxmi->bus->phy_mask = ~0; + dxmi->bus->parent = dev; + dxmi->bus->priv = dxmi; + + snprintf(dxmi->bus->id, MII_BUS_ID_SIZE, + "dwxpcs-%x", atomic_inc_return(&id)); + + ret = devm_of_mdiobus_register(dev, dxmi->bus, dev_of_node(dev)); + if (ret) { + dev_err(dev, "Failed to create MDIO bus\n"); + return ret; + } + + return 0; +} + +static int dw_xpcs_mi_probe(struct platform_device *pdev) +{ + struct dw_xpcs_mi *dxmi; + int ret; + + dxmi = dw_xpcs_mi_create_data(pdev); + if (IS_ERR(dxmi)) + return PTR_ERR(dxmi); + + ret = dw_xpcs_mi_init_res(dxmi); + if (ret) + return ret; + + ret = dw_xpcs_mi_init_clk(dxmi); + if (ret) + return ret; + + ret = dw_xpcs_mi_init_mdio(dxmi); + if (ret) + return ret; + + return 0; +} + +static int __maybe_unused dw_xpcs_mi_pm_runtime_suspend(struct device *dev) +{ + struct dw_xpcs_mi *dxmi = dev_get_drvdata(dev); + + clk_disable_unprepare(dxmi->pclk); + + return 0; +} + +static int __maybe_unused dw_xpcs_mi_pm_runtime_resume(struct device *dev) +{ + struct dw_xpcs_mi *dxmi = dev_get_drvdata(dev); + + return clk_prepare_enable(dxmi->pclk); +} + +const struct dev_pm_ops dw_xpcs_mi_pm_ops = { + SET_RUNTIME_PM_OPS(dw_xpcs_mi_pm_runtime_suspend, dw_xpcs_mi_pm_runtime_resume, NULL) +}; + +static const struct of_device_id dw_xpcs_mi_of_ids[] = { + { .compatible = "snps,dw-xpcs-mi" }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, dw_xpcs_mi_of_ids); + +static struct platform_driver dw_xpcs_mi_driver = { + .probe = dw_xpcs_mi_probe, + .driver = { + .name = "dw-xpcs-mi", + .pm = &dw_xpcs_mi_pm_ops, + .of_match_table = dw_xpcs_mi_of_ids, + }, +}; + +module_platform_driver(dw_xpcs_mi_driver); + +MODULE_DESCRIPTION("Synopsys DesignWare XPCS Management Interface driver"); +MODULE_AUTHOR("Serge Semin "); +MODULE_LICENSE("GPL v2"); -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:31 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:31 +0300 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-11-fancer.lancer@gmail.com> Recently the memory mapped Synopsys DW XPCS management interface support was added to the kernel. In that case the DW XPCS device can be registered via a standard MDIO-bus subsystem. In order to have such devices fully accessible and properly configured let's add a respective functionality to the DW XPCS driver. The main goal of this update is to add a functionality to activate vendor-specific XPCS capabilities in the driver (like a limited number of network interfaces, linkmodes, PMA-specific initializations). It's reached by having DW XPCS devices registered as the platform devices (OF, ACPI, legacy platform ,etc). From that point of view the suggested update is threefold. First the driver is now capable to be attached to the OF-devices registered on the MDIO-bus with the "snps,dw-xpcs*" compatible string. Second it's possible to have the driver bound to the DW XPCS device with no OF/ACPI-nodes by means of defining the mdio_board_info descriptor and registering one with mdiobus_register_board_info() (see dwmac-intel.c for example). Thirdly it's still possible to use the unregistered device to auto-detect the DW XPCS device on the MDIO bus. In all these cases the DW XPCS device info can be passed by means of the driver-data pointer (of_device_id.data or device.platform_data). In addition to that the update provides the DW XPCS reference clock sources request and enabling. These clocks are named as "core" and "pad" as per the DT-bindings. Note normally they are mutually exclusive: only one of them can be used at a time, but the system software is responsible for switching between them. Such functionality will be added later in the framework of the pma_config() internal callback. Note all the platform resources initialization is performed in the externally called xpcs_create() method as before this update. The only crucial update is that it now makes sure that the device is bound to the DW XPCS driver if it's possible. Otherwise the legacy auto-detection procedure takes place as before. Moreover due to that semantic there is no device probe() and remove() methods defined since there is nothing left to initialize/de-initialize on these stages. Signed-off-by: Serge Semin --- drivers/net/pcs/Kconfig | 6 +- drivers/net/pcs/pcs-xpcs.c | 112 ++++++++++++++++++++++++++++++++--- drivers/net/pcs/pcs-xpcs.h | 6 ++ include/linux/pcs/pcs-xpcs.h | 27 +++++++++ 4 files changed, 141 insertions(+), 10 deletions(-) diff --git a/drivers/net/pcs/Kconfig b/drivers/net/pcs/Kconfig index 87cf308fc6d8..f6aa437473de 100644 --- a/drivers/net/pcs/Kconfig +++ b/drivers/net/pcs/Kconfig @@ -6,11 +6,11 @@ menu "PCS device drivers" config PCS_XPCS - tristate + tristate "Synopsys DesignWare Ethernet XPCS" select PHYLINK help - This module provides helper functions for Synopsys DesignWare XPCS - controllers. + This module provides a driver and helper functions for Synopsys + DesignWare XPCS controllers. config PCS_LYNX tristate diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index ea6f56339595..183a37929b60 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -6,10 +6,14 @@ * Author: Jose Abreu */ +#include #include -#include +#include #include +#include +#include #include +#include #include "pcs-xpcs.h" @@ -1386,17 +1390,57 @@ static void xpcs_free_data(struct dw_xpcs *xpcs) kfree(xpcs); } +static int xpcs_init_clks(struct dw_xpcs *xpcs) +{ + static const char *ids[DW_XPCS_NUM_CLKS] = { + [DW_XPCS_CLK_CORE] = "core", + [DW_XPCS_CLK_PAD] = "pad", + }; + struct device *dev = &xpcs->mdiodev->dev; + int ret, i; + + for (i = 0; i < DW_XPCS_NUM_CLKS; ++i) + xpcs->clks[i].id = ids[i]; + + ret = clk_bulk_get_optional(dev, DW_XPCS_NUM_CLKS, xpcs->clks); + if (ret) + return dev_err_probe(dev, ret, "Failed to get clocks\n"); + + ret = clk_bulk_prepare_enable(DW_XPCS_NUM_CLKS, xpcs->clks); + if (ret) + return dev_err_probe(dev, ret, "Failed to enable clocks\n"); + + return 0; +} + +static void xpcs_clear_clks(struct dw_xpcs *xpcs) +{ + clk_bulk_disable_unprepare(DW_XPCS_NUM_CLKS, xpcs->clks); + + clk_bulk_put(DW_XPCS_NUM_CLKS, xpcs->clks); +} + static int xpcs_init_id(struct dw_xpcs *xpcs) { - u32 xpcs_id; + const struct dw_xpcs_info *info; int i, ret; - xpcs_id = xpcs_get_id(xpcs); + info = device_get_match_data(&xpcs->mdiodev->dev) ?: + dev_get_platdata(&xpcs->mdiodev->dev); + if (!info) { + xpcs->info.did = DW_XPCS_ID_NATIVE; + xpcs->info.pma = DW_XPCS_PMA_UNKNOWN; + } else { + xpcs->info = *info; + } + + if (xpcs->info.did == DW_XPCS_ID_NATIVE) + xpcs->info.did = xpcs_get_id(xpcs); for (i = 0; i < ARRAY_SIZE(xpcs_id_list); i++) { const struct xpcs_id *entry = &xpcs_id_list[i]; - if ((xpcs_id & entry->mask) != entry->id) + if ((xpcs->info.did & entry->mask) != entry->id) continue; xpcs->id = entry; @@ -1436,21 +1480,32 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, struct dw_xpcs *xpcs; int ret; + ret = device_attach(&mdiodev->dev); + if (ret < 0 && ret != -ENODEV) + return ERR_PTR(ret); + xpcs = xpcs_create_data(mdiodev); if (IS_ERR(xpcs)) return xpcs; + ret = xpcs_init_clks(xpcs); + if (ret) + goto out_free_data; + ret = xpcs_init_id(xpcs); if (ret) - goto out; + goto out_clear_clks; ret = xpcs_init_iface(xpcs, interface); if (ret) - goto out; + goto out_clear_clks; return xpcs; -out: +out_clear_clks: + xpcs_clear_clks(xpcs); + +out_free_data: xpcs_free_data(xpcs); return ERR_PTR(ret); @@ -1489,8 +1544,51 @@ void xpcs_destroy(struct dw_xpcs *xpcs) mdio_device_put(xpcs->mdiodev); + xpcs_clear_clks(xpcs); + xpcs_free_data(xpcs); } EXPORT_SYMBOL_GPL(xpcs_destroy); +DW_XPCS_INFO_DECLARE(xpcs_generic, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_UNKNOWN); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen1_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN1_3G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen2_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN2_3G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen2_6g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN2_6G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen4_3g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN4_3G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen4_6g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN4_6G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen5_10g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN5_10G); +DW_XPCS_INFO_DECLARE(xpcs_pma_gen5_12g, DW_XPCS_ID_NATIVE, DW_XPCS_PMA_GEN5_12G); + +static const struct of_device_id xpcs_of_ids[] = { + { .compatible = "snps,dw-xpcs", .data = &xpcs_generic }, + { .compatible = "snps,dw-xpcs-gen1-3g", .data = &xpcs_pma_gen1_3g }, + { .compatible = "snps,dw-xpcs-gen2-3g", .data = &xpcs_pma_gen2_3g }, + { .compatible = "snps,dw-xpcs-gen2-6g", .data = &xpcs_pma_gen2_6g }, + { .compatible = "snps,dw-xpcs-gen4-3g", .data = &xpcs_pma_gen4_3g }, + { .compatible = "snps,dw-xpcs-gen4-6g", .data = &xpcs_pma_gen4_6g }, + { .compatible = "snps,dw-xpcs-gen5-10g", .data = &xpcs_pma_gen5_10g }, + { .compatible = "snps,dw-xpcs-gen5-12g", .data = &xpcs_pma_gen5_12g }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, xpcs_of_ids); + +static struct mdio_device_id __maybe_unused xpcs_mdio_ids[] = { + { DW_XPCS_ID, DW_XPCS_ID_MASK }, + { NXP_SJA1105_XPCS_ID, DW_XPCS_ID_MASK }, + { NXP_SJA1110_XPCS_ID, DW_XPCS_ID_MASK }, + { } +}; +MODULE_DEVICE_TABLE(mdio, xpcs_mdio_ids); + +static struct mdio_driver xpcs_driver = { + .mdiodrv.driver = { + .name = "dwxpcs", + .of_match_table = xpcs_of_ids, + .probe_type = PROBE_FORCE_SYNCHRONOUS, + }, +}; +mdio_module_driver(xpcs_driver); + +MODULE_DESCRIPTION("DWC Ethernet XPCS platform driver"); +MODULE_AUTHOR("Jose Abreu "); MODULE_LICENSE("GPL v2"); diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h index 369e9196f45a..45fea2641d23 100644 --- a/drivers/net/pcs/pcs-xpcs.h +++ b/drivers/net/pcs/pcs-xpcs.h @@ -6,6 +6,9 @@ * Author: Jose Abreu */ +#include +#include + /* Vendor regs access */ #define DW_VENDOR BIT(15) @@ -117,6 +120,9 @@ /* VR MII EEE Control 1 defines */ #define DW_VR_MII_EEE_TRN_LPI BIT(0) /* Transparent Mode Enable */ +#define DW_XPCS_INFO_DECLARE(_name, _did, _pma) \ + static const struct dw_xpcs_info _name = { .did = _did, .pma = _pma } + int xpcs_read(struct dw_xpcs *xpcs, int dev, u32 reg); int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val); int xpcs_read_vpcs(struct dw_xpcs *xpcs, int reg); diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 8dfe90295f12..53adbffb4c0a 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -7,9 +7,12 @@ #ifndef __LINUX_PCS_XPCS_H #define __LINUX_PCS_XPCS_H +#include +#include #include #include +#define DW_XPCS_ID_NATIVE 0x00000000 #define NXP_SJA1105_XPCS_ID 0x00000010 #define NXP_SJA1110_XPCS_ID 0x00000020 #define DW_XPCS_ID 0x7996ced0 @@ -30,9 +33,33 @@ struct xpcs_id; +enum dw_xpcs_pma { + DW_XPCS_PMA_UNKNOWN = 0, + DW_XPCS_PMA_GEN1_3G, + DW_XPCS_PMA_GEN2_3G, + DW_XPCS_PMA_GEN2_6G, + DW_XPCS_PMA_GEN4_3G, + DW_XPCS_PMA_GEN4_6G, + DW_XPCS_PMA_GEN5_10G, + DW_XPCS_PMA_GEN5_12G, +}; + +enum dw_xpcs_clock { + DW_XPCS_CLK_CORE, + DW_XPCS_CLK_PAD, + DW_XPCS_NUM_CLKS, +}; + +struct dw_xpcs_info { + u32 did; + u32 pma; +}; + struct dw_xpcs { struct mdio_device *mdiodev; + struct dw_xpcs_info info; const struct xpcs_id *id; + struct clk_bulk_data clks[DW_XPCS_NUM_CLKS]; struct phylink_pcs pcs; phy_interface_t interface; int dev_flag; -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:32 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:32 +0300 Subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-12-fancer.lancer@gmail.com> The fwnode-based way of creating XPCS descriptor is about to be added. In order to have a function name distinguishable from the already implemented xpcs_create_mdiodev() method convert the later name to be xpcs_create_byaddr() which BTW better describes the method semantic in anyway. Signed-off-by: Serge Semin --- drivers/net/dsa/sja1105/sja1105_mdio.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 2 +- drivers/net/pcs/pcs-xpcs.c | 6 +++--- include/linux/pcs/pcs-xpcs.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/sja1105/sja1105_mdio.c b/drivers/net/dsa/sja1105/sja1105_mdio.c index 833e55e4b961..9101079e365d 100644 --- a/drivers/net/dsa/sja1105/sja1105_mdio.c +++ b/drivers/net/dsa/sja1105/sja1105_mdio.c @@ -409,7 +409,7 @@ static int sja1105_mdiobus_pcs_register(struct sja1105_private *priv) priv->phy_mode[port] != PHY_INTERFACE_MODE_2500BASEX) continue; - xpcs = xpcs_create_mdiodev(bus, port, priv->phy_mode[port]); + xpcs = xpcs_create_byaddr(bus, port, priv->phy_mode[port]); if (IS_ERR(xpcs)) { rc = PTR_ERR(xpcs); goto out_pcs_free; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index fa9e7e7040b9..aa75e4f1e212 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -507,7 +507,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_mdiodev(bus, addr, mode); + xpcs = xpcs_create_byaddr(bus, addr, mode); if (IS_ERR(xpcs)) continue; diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 183a37929b60..e376e255f1d3 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -1511,8 +1511,8 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, return ERR_PTR(ret); } -struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, - phy_interface_t interface) +struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, + phy_interface_t interface) { struct mdio_device *mdiodev; struct dw_xpcs *xpcs; @@ -1535,7 +1535,7 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, return xpcs; } -EXPORT_SYMBOL_GPL(xpcs_create_mdiodev); +EXPORT_SYMBOL_GPL(xpcs_create_byaddr); void xpcs_destroy(struct dw_xpcs *xpcs) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index 53adbffb4c0a..b11bbb5e820a 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -73,8 +73,8 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); -struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, - phy_interface_t interface); +struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, + phy_interface_t interface); void xpcs_destroy(struct dw_xpcs *xpcs); #endif /* __LINUX_PCS_XPCS_H */ -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:33 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:33 +0300 Subject: [PATCH net-next 12/16] net: pcs: xpcs: Add xpcs_create_bynode() method In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-13-fancer.lancer@gmail.com> It's now possible to have the DW XPCS device defined as a standard platform device for instance in the platform DT-file. Although it's pointless unless there is a way to have the device found by the client drivers (STMMAC/DW *MAC, NXP SJA1105 Eth Switch, etc). Provide such ability by means of the xpcs_create_bynode() method. It needs to be supplied with the device fwnode which is equipped with the "pcs-handle" property pointing to the DW XPCS fw-node (in this regards it looks similar to the phylink interface). That node will be then used to find the MDIO-device instance in order to create the DW XPCS descriptor. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 26 ++++++++++++++++++++++++++ include/linux/pcs/pcs-xpcs.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index e376e255f1d3..c3336895a124 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -9,9 +9,11 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -1511,6 +1513,30 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, return ERR_PTR(ret); } +struct dw_xpcs *xpcs_create_bynode(const struct fwnode_handle *fwnode, + phy_interface_t interface) +{ + struct fwnode_handle *pcs_node; + struct mdio_device *mdiodev; + struct dw_xpcs *xpcs; + + pcs_node = fwnode_find_reference(fwnode, "pcs-handle", 0); + if (IS_ERR(pcs_node)) + return ERR_CAST(pcs_node); + + mdiodev = fwnode_mdio_find_device(pcs_node); + fwnode_handle_put(pcs_node); + if (!mdiodev) + return ERR_PTR(-ENODEV); + + xpcs = xpcs_create(mdiodev, interface); + if (IS_ERR(xpcs)) + mdio_device_put(mdiodev); + + return xpcs; +} +EXPORT_SYMBOL_GPL(xpcs_create_bynode); + struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, phy_interface_t interface) { diff --git a/include/linux/pcs/pcs-xpcs.h b/include/linux/pcs/pcs-xpcs.h index b11bbb5e820a..2981dcdf65d4 100644 --- a/include/linux/pcs/pcs-xpcs.h +++ b/include/linux/pcs/pcs-xpcs.h @@ -8,6 +8,7 @@ #define __LINUX_PCS_XPCS_H #include +#include #include #include #include @@ -73,6 +74,8 @@ int xpcs_do_config(struct dw_xpcs *xpcs, phy_interface_t interface, void xpcs_get_interfaces(struct dw_xpcs *xpcs, unsigned long *interfaces); int xpcs_config_eee(struct dw_xpcs *xpcs, int mult_fact_100ns, int enable); +struct dw_xpcs *xpcs_create_bynode(const struct fwnode_handle *fwnode, + phy_interface_t interface); struct dw_xpcs *xpcs_create_byaddr(struct mii_bus *bus, int addr, phy_interface_t interface); void xpcs_destroy(struct dw_xpcs *xpcs); -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:34 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:34 +0300 Subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-14-fancer.lancer@gmail.com> The DW XPCS driver has been updated to being bindable with the respective MDIO device registered during the MDIO bus probe procedure. As an example of using that feature let's convert the Intel mGBE low-level driver to registering the MDIO-device board info. Thus the registered DW XPCS device will be a subject of the fine-tunings performed during the MDIO-device probe procedures. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/dwmac-intel.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c index 60283543ffc8..7642c11abc59 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c @@ -4,6 +4,7 @@ #include #include +#include #include #include "dwmac-intel.h" #include "dwmac4.h" @@ -585,6 +586,28 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, /* Intel mgbe SGMII interface uses pcs-xcps */ if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { + struct mdio_board_info *xpcs_info; + + xpcs_info = devm_kzalloc(&pdev->dev, + sizeof(*xpcs_info) + MII_BUS_ID_SIZE, + GFP_KERNEL); + if (!xpcs_info) { + ret = -ENOMEM; + goto err_alloc_info; + } + + xpcs_info->bus_id = (void *)xpcs_info + sizeof(*xpcs_info); + snprintf((char *)xpcs_info->bus_id, MII_BUS_ID_SIZE, + "stmmac-%x", plat->bus_id); + + snprintf(xpcs_info->modalias, MDIO_NAME_SIZE, "dwxpcs"); + + xpcs_info->mdio_addr = INTEL_MGBE_XPCS_ADDR; + + ret = mdiobus_register_board_info(xpcs_info, 1); + if (ret) + goto err_alloc_info; + plat->mdio_bus_data->has_xpcs = true; plat->mdio_bus_data->xpcs_an_inband = true; } @@ -600,7 +623,7 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, fwnode_handle_put(fixed_node); } - /* Ensure mdio bus scan skips intel serdes and pcs-xpcs */ + /* Ensure mdio bus PHY-scan skips intel serdes and pcs-xpcs */ plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; @@ -618,6 +641,12 @@ static int intel_mgbe_common_data(struct pci_dev *pdev, plat->msi_tx_base_vec = 1; return 0; + +err_alloc_info: + clk_disable_unprepare(clk); + clk_unregister_fixed_rate(clk); + + return ret; } static int ehl_common_data(struct pci_dev *pdev, -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:35 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:35 +0300 Subject: [PATCH net-next 14/16] net: stmmac: Pass netdev to XPCS setup function In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-15-fancer.lancer@gmail.com> It's possible to have the XPCS device accessible over a dedicated management interface which makes the XPCS device available over the MMIO space. In that case the management interface will be registered as a separate MDIO bus and the DW xGMAC device will be equipped with the "pcs-handle" property pointing to the XPCS device instead of auto-detecting it on the internal MDIO bus. In such configurations the SMA interface (embedded into the DW xGMAC MDIO interface) might be absent. Thus passing the MII bus interface handler to the stmmac_xpcs_setup() method won't let us reach the externally supplied XPCS device especially if the SMA bus isn't configured. Let's fix it by converting the stmmac_xpcs_setup(struct mii_bus *bus) prototype to stmmac_xpcs_setup(struct net_device *ndev). Note this is a preparation patch before adding the support of the XPCS devices specified via the "pcs-handle" property. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index cd7a9768de5f..d8a1c84880c5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -343,7 +343,7 @@ enum stmmac_state { int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); -int stmmac_xpcs_setup(struct mii_bus *mii); +int stmmac_xpcs_setup(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 3e50fd53a617..c3641db00f96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7605,7 +7605,7 @@ int stmmac_dvr_probe(struct device *device, priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(priv->mii); + ret = stmmac_xpcs_setup(ndev); if (ret) goto error_xpcs_setup; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index aa75e4f1e212..e6133510e28d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -495,9 +495,8 @@ int stmmac_mdio_reset(struct mii_bus *bus) return 0; } -int stmmac_xpcs_setup(struct mii_bus *bus) +int stmmac_xpcs_setup(struct net_device *ndev) { - struct net_device *ndev = bus->priv; struct stmmac_priv *priv; struct dw_xpcs *xpcs; int mode, addr; @@ -507,7 +506,7 @@ int stmmac_xpcs_setup(struct mii_bus *bus) /* Try to probe the XPCS by scanning all addresses. */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_byaddr(bus, addr, mode); + xpcs = xpcs_create_byaddr(priv->mii, addr, mode); if (IS_ERR(xpcs)) continue; -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:36 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:36 +0300 Subject: [PATCH net-next 15/16] net: stmmac: Add dedicated XPCS cleanup method In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-16-fancer.lancer@gmail.com> Currently the XPCS handler destruction is performed in the stmmac_mdio_unregister() method. It doesn't look well because the handler isn't originally created in the corresponding protagonist stmmac_mdio_unregister(), but in the stmmac_xpcs_setup() function. In order to have a bit more coherent MDIO and XPCS setup/cleanup procedures let's move the DW XPCS destruction to the dedicated stmmac_xpcs_clean() method. Note besides of that this change is a preparation to adding the PCS device supplied by means of the "pcs-handle" property. It's required since DW XPCS IP-core can be synthesized embedded into the chip with directly accessible CSRs. In that case the SMA interface can be absent so no corresponding MDIO bus will be registered. Signed-off-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++++- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 +++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index d8a1c84880c5..1709de519813 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -344,6 +344,7 @@ int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); int stmmac_xpcs_setup(struct net_device *ndev); +void stmmac_xpcs_clean(struct net_device *ndev); void stmmac_set_ethtool_ops(struct net_device *netdev); int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c3641db00f96..379552240ac9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7639,8 +7639,9 @@ int stmmac_dvr_probe(struct device *device, error_netdev_register: phylink_destroy(priv->phylink); -error_xpcs_setup: error_phy_setup: + stmmac_xpcs_clean(ndev); +error_xpcs_setup: if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); @@ -7682,6 +7683,9 @@ void stmmac_dvr_remove(struct device *dev) if (priv->plat->stmmac_rst) reset_control_assert(priv->plat->stmmac_rst); reset_control_assert(priv->plat->stmmac_ahb_rst); + + stmmac_xpcs_clean(ndev); + if (priv->hw->pcs != STMMAC_PCS_TBI && priv->hw->pcs != STMMAC_PCS_RTBI) stmmac_mdio_unregister(ndev); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index e6133510e28d..101fa50c3c96 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -522,6 +522,17 @@ int stmmac_xpcs_setup(struct net_device *ndev) return 0; } +void stmmac_xpcs_clean(struct net_device *ndev) +{ + struct stmmac_priv *priv = netdev_priv(ndev); + + if (!priv->hw->xpcs) + return; + + xpcs_destroy(priv->hw->xpcs); + priv->hw->xpcs = NULL; +} + /** * stmmac_mdio_register * @ndev: net device structure @@ -674,9 +685,6 @@ int stmmac_mdio_unregister(struct net_device *ndev) if (!priv->mii) return 0; - if (priv->hw->xpcs) - xpcs_destroy(priv->hw->xpcs); - mdiobus_unregister(priv->mii); priv->mii->priv = NULL; mdiobus_free(priv->mii); -- 2.42.1 From fancer.lancer at gmail.com Tue Dec 5 21:35:37 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 13:35:37 +0300 Subject: [PATCH net-next 16/16] net: stmmac: Add externally detected DW XPCS support In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> Message-ID: <20231205103559.9605-17-fancer.lancer@gmail.com> It's possible to have the DW XPCS device accessible over an external bus (external MDIO or DW XPCS management interface). Thus it will be futile to try to detect the device on the local SMA interface. Besides such platform setup isn't supported by the STMMAC driver anyway since the stmmac_mdio_bus_data instance might not be created and even if it is there is no code path which would set the stmmac_mdio_bus_data.has_xpcs flag thus activating the XPCS device setup. So in order to solve the denoted problem a pretty much standard approach is implemented: DT "pcs-handle" property is used to get the phandle referencing the DT-node describing the DW XPCS device; device node will be parsed by the xpcs_create_bynode() method implemented in the DW XPCS driver in a way as it's done for PHY-node; the node is used to find the MDIO-device instance, which in its turn will be used to create the XPCS descriptor. Note as a nice side effect of the provided change the conditional stmmac_xpcs_setup() method execution can be converted to the conditional statements implemented in the function itself. Thus the stmmac_open() will turn to look a bit simpler meanwhile stmmac_xpcs_setup() will provide the optional XPCS device semantic. Signed-off-by: Serge Semin --- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 8 ++--- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 34 ++++++++++++------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 379552240ac9..a33ba00d091d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -7604,11 +7604,9 @@ int stmmac_dvr_probe(struct device *device, if (priv->plat->speed_mode_2500) priv->plat->speed_mode_2500(ndev, priv->plat->bsp_priv); - if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { - ret = stmmac_xpcs_setup(ndev); - if (ret) - goto error_xpcs_setup; - } + ret = stmmac_xpcs_setup(ndev); + if (ret) + goto error_xpcs_setup; ret = stmmac_phy_setup(priv); if (ret) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index 101fa50c3c96..b906be363b61 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -499,25 +499,33 @@ int stmmac_xpcs_setup(struct net_device *ndev) { struct stmmac_priv *priv; struct dw_xpcs *xpcs; - int mode, addr; + int ret, mode, addr; priv = netdev_priv(ndev); mode = priv->plat->phy_interface; - /* Try to probe the XPCS by scanning all addresses. */ - for (addr = 0; addr < PHY_MAX_ADDR; addr++) { - xpcs = xpcs_create_byaddr(priv->mii, addr, mode); - if (IS_ERR(xpcs)) - continue; - - priv->hw->xpcs = xpcs; - break; + /* If PCS-node is specified use it to create the XPCS descriptor */ + if (fwnode_property_present(priv->plat->port_node, "pcs-handle")) { + xpcs = xpcs_create_bynode(priv->plat->port_node, mode); + ret = PTR_ERR_OR_ZERO(xpcs); + } else if (priv->plat->mdio_bus_data && priv->plat->mdio_bus_data->has_xpcs) { + /* Try to probe the XPCS by scanning all addresses */ + for (ret = -ENODEV, addr = 0; addr < PHY_MAX_ADDR; addr++) { + xpcs = xpcs_create_byaddr(priv->mii, addr, mode); + if (IS_ERR(xpcs)) + continue; + + ret = 0; + break; + } + } else { + return 0; } - if (!priv->hw->xpcs) { - dev_warn(priv->device, "No xPCS found\n"); - return -ENODEV; - } + if (ret) + return dev_err_probe(priv->device, ret, "No xPCS found\n"); + + priv->hw->xpcs = xpcs; return 0; } -- 2.42.1 From linux at armlinux.org.uk Tue Dec 5 21:45:34 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 10:45:34 +0000 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: <20231205103559.9605-6-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 01:35:26PM +0300, Serge Semin wrote: > Generic MDIO-device driver will support setting a custom device ID for the > particular MDIO-device. Why future tense? I don't see anything later in this patch set adding this. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From linux at armlinux.org.uk Tue Dec 5 21:49:47 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 10:49:47 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: <20231205103559.9605-7-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > or explicitly registered in the MDIO subsystem by means of the > mdiobus_register_board_info() method there is no point in creating the > dummy MDIO device instance in order to get the DW XPCS handler since the > MDIO core subsystem will create the device during the MDIO bus > registration procedure. Please reword this overly long sentence. If they're left unmasked, what prevents them being created as PHY devices? > @@ -1437,19 +1435,21 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, > struct mdio_device *mdiodev; > struct dw_xpcs *xpcs; > > - mdiodev = mdio_device_create(bus, addr); > - if (IS_ERR(mdiodev)) > - return ERR_CAST(mdiodev); > + if (addr >= PHY_MAX_ADDR) > + return ERR_PTR(-EINVAL); > > - xpcs = xpcs_create(mdiodev, interface); > + if (mdiobus_is_registered_device(bus, addr)) { > + mdiodev = bus->mdio_map[addr]; > + mdio_device_get(mdiodev); No, this makes no sense now. This function is called xpcs_create_mdiodev() - note the "create_mdiodev" part. If it's getting the mdiodev from what is already there then it isn't creating it, so it's no longer doing what it says in its function name. If you want to add this functionality, create a new function to do it. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From lkp at intel.com Tue Dec 5 22:04:30 2023 From: lkp at intel.com (kernel test robot) Date: Tue, 5 Dec 2023 19:04:30 +0800 Subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X In-Reply-To: <20231204055650.788388-3-kcfeng0@nuvoton.com> References: <20231204055650.788388-3-kcfeng0@nuvoton.com> Message-ID: <202312051854.qBIoJW1N-lkp@intel.com> Hi, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.7-rc4 next-20231205] [cannot apply to groeck-staging/hwmon-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/baneric926-gmail-com/dt-bindings-hwmon-Add-nct736x-bindings/20231204-135942 base: linus/master patch link: https://lore.kernel.org/r/20231204055650.788388-3-kcfeng0%40nuvoton.com patch subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20231205/202312051854.qBIoJW1N-lkp at intel.com/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/202312051854.qBIoJW1N-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312051854.qBIoJW1N-lkp at intel.com/ All warnings (new ones prefixed by >>): >> drivers/hwmon/nct736x.c:352:5: warning: variable 'gpio14_17' is uninitialized when used here [-Wuninitialized] gpio14_17 |= FANIN_SEL(i); ^~~~~~~~~ drivers/hwmon/nct736x.c:339:46: note: initialize the variable 'gpio14_17' to silence this warning u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; ^ = '\0' >> drivers/hwmon/nct736x.c:347:5: warning: variable 'gpio10_13' is uninitialized when used here [-Wuninitialized] gpio10_13 |= FANIN_SEL(i); ^~~~~~~~~ drivers/hwmon/nct736x.c:339:35: note: initialize the variable 'gpio10_13' to silence this warning u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; ^ = '\0' >> drivers/hwmon/nct736x.c:350:5: warning: variable 'gpio4_7' is uninitialized when used here [-Wuninitialized] gpio4_7 |= PWM_SEL(i); ^~~~~~~ drivers/hwmon/nct736x.c:339:24: note: initialize the variable 'gpio4_7' to silence this warning u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; ^ = '\0' >> drivers/hwmon/nct736x.c:345:5: warning: variable 'gpio0_3' is uninitialized when used here [-Wuninitialized] gpio0_3 |= PWM_SEL(i); ^~~~~~~ drivers/hwmon/nct736x.c:339:15: note: initialize the variable 'gpio0_3' to silence this warning u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; ^ = '\0' 4 warnings generated. vim +/gpio14_17 +352 drivers/hwmon/nct736x.c 334 335 static int nct736x_init_chip(struct i2c_client *client, 336 u32 pwm_mask, u32 fanin_mask, u32 wdt_cfg) 337 { 338 const struct i2c_device_id *id = i2c_match_id(nct736x_id, client); 339 u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; 340 int ret; 341 342 for (i = 0; i < NCT736X_PWM_COUNT; i++) { 343 if (i < 4) { 344 if (pwm_mask & BIT_CHECK(i)) > 345 gpio0_3 |= PWM_SEL(i); 346 if (fanin_mask & BIT_CHECK(i)) > 347 gpio10_13 |= FANIN_SEL(i); 348 } else if (i < 8) { 349 if (pwm_mask & BIT_CHECK(i)) > 350 gpio4_7 |= PWM_SEL(i); 351 if (fanin_mask & BIT_CHECK(i)) > 352 gpio14_17 |= FANIN_SEL(i); 353 } else if (i < 12) { 354 if (pwm_mask & BIT_CHECK(i)) 355 gpio10_13 |= PWM_SEL(i); 356 if (fanin_mask & BIT_CHECK(i)) 357 gpio0_3 |= FANIN_SEL(i); 358 } else { 359 if (pwm_mask & BIT_CHECK(i)) 360 gpio14_17 |= PWM_SEL(i); 361 if (fanin_mask & BIT_CHECK(i)) 362 gpio4_7 |= FANIN_SEL(i); 363 } 364 } 365 366 /* Pin Function Configuration */ 367 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_0_3, gpio0_3); 368 if (ret < 0) 369 return ret; 370 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_4_7, gpio4_7); 371 if (ret < 0) 372 return ret; 373 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_10_13, gpio10_13); 374 if (ret < 0) 375 return ret; 376 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_14_17, gpio14_17); 377 if (ret < 0) 378 return ret; 379 380 /* PWM and FANIN Monitoring Enable */ 381 ret = nct736x_write_reg(client, NCT736X_REG_PWMEN_0_7, 382 pwm_mask & 0xff); 383 if (ret < 0) 384 return ret; 385 ret = nct736x_write_reg(client, 386 NCT736X_REG_PWMEN_8_15, (pwm_mask >> 8) & 0xff); 387 if (ret < 0) 388 return ret; 389 ret = nct736x_write_reg(client, NCT736X_REG_FANINEN_0_7, 390 fanin_mask & 0xff); 391 if (ret < 0) 392 return ret; 393 ret = nct736x_write_reg(client, NCT736X_REG_FANINEN_8_15, 394 (fanin_mask >> 8) & 0xff); 395 if (ret < 0) 396 return ret; 397 398 /* Watchdog Timer Configuration */ 399 if (wdt_cfg != 0xff && id->driver_data == nct7363) { 400 ret = nct736x_write_reg(client, NCT7363_REG_WDT, wdt_cfg); 401 if (ret < 0) 402 return ret; 403 } 404 405 return 0; 406 } 407 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From olteanv at gmail.com Tue Dec 5 22:13:51 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Tue, 5 Dec 2023 13:13:51 +0200 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: <20231205103559.9605-11-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> Message-ID: <20231205111351.xjjuwpbf7kwg3vuh@skbuf> On Tue, Dec 05, 2023 at 01:35:31PM +0300, Serge Semin wrote: > @@ -1436,21 +1480,32 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > struct dw_xpcs *xpcs; > int ret; > > + ret = device_attach(&mdiodev->dev); > + if (ret < 0 && ret != -ENODEV) > + return ERR_PTR(ret); > + > xpcs = xpcs_create_data(mdiodev); > if (IS_ERR(xpcs)) > return xpcs; > > + ret = xpcs_init_clks(xpcs); > + if (ret) > + goto out_free_data; > + > ret = xpcs_init_id(xpcs); > if (ret) > - goto out; > + goto out_clear_clks; > > ret = xpcs_init_iface(xpcs, interface); > if (ret) > - goto out; > + goto out_clear_clks; > > return xpcs; [ 4.083518] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000d0 [ 4.092356] Mem abort info: [ 4.095164] ESR = 0x0000000096000004 [ 4.098932] EC = 0x25: DABT (current EL), IL = 32 bits [ 4.104277] SET = 0, FnV = 0 [ 4.107352] EA = 0, S1PTW = 0 [ 4.110505] FSC = 0x04: level 0 translation fault [ 4.115408] Data abort info: [ 4.118296] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 [ 4.123807] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 [ 4.128877] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 [ 4.134214] [00000000000000d0] user address but active_mm is swapper [ 4.140595] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP [ 4.146882] Modules linked in: [ 4.149944] CPU: 0 PID: 11 Comm: kworker/u4:0 Not tainted 6.7.0-rc3-00719-g75be5ea8e111-dirty #1551 [ 4.164524] Workqueue: events_unbound deferred_probe_work_func [ 4.177372] pc : __device_attach+0x3c/0x1bc [ 4.181570] lr : __device_attach+0x38/0x1bc [ 4.185767] sp : ffff8000800f3800 [ 4.189087] x29: ffff8000800f3820 x28: 0000000000000001 x27: ffff063781bda150 [ 4.196252] x26: ffff063781bda150 x25: ffff063780827480 x24: ffffcb9a08138a40 [ 4.203416] x23: ffff063781114080 x22: 0000000000000000 x21: 0000000000000004 [ 4.210579] x20: ffff06378123a400 x19: ffff06378123a480 x18: ffffcb9a07c703a0 [ 4.217743] x17: ffffcb9a07c703a4 x16: 00000000000000d4 x15: ffffcb9a07be70fc [ 4.224906] x14: ffffcb9a08299638 x13: 0000000000000053 x12: ffff003000000200 [ 4.232069] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 [ 4.239233] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 000000000000003a [ 4.246396] x5 : ffff0637809a037b x4 : ffffcb9a087b0d47 x3 : ffff10300000020f [ 4.253560] x2 : ffffcb9a0910c561 x1 : 0000000000000000 x0 : ffff06378123a480 [ 4.260724] Call trace: [ 4.263172] __device_attach+0x3c/0x1bc [ 4.267020] device_attach+0x14/0x20 [ 4.270606] xpcs_create+0x24/0x384 [ 4.274107] xpcs_create_byaddr+0x74/0xa0 [ 4.278129] sja1105_mdiobus_register+0xf8/0x478 [ 4.282763] sja1105_setup+0xb4/0x1194 [ 4.286524] dsa_register_switch+0xab0/0x11f8 [ 4.290895] sja1105_probe+0x2bc/0x2e4 [ 4.294654] spi_probe+0xa4/0xc4 [ 4.297890] really_probe+0x16c/0x3fc [ 4.301564] __driver_probe_device+0xa4/0x168 [ 4.305935] driver_probe_device+0x3c/0x220 [ 4.310131] __device_attach_driver+0x128/0x1cc [ 4.314676] bus_for_each_drv+0xf4/0x14c [ 4.318610] __device_attach+0xfc/0x1bc [ 4.322457] device_initial_probe+0x14/0x20 [ 4.326654] bus_probe_device+0x94/0x100 [ 4.330587] deferred_probe_work_func+0xa0/0xfc [ 4.335132] process_scheduled_works+0x210/0x318 [ 4.339764] worker_thread+0x28c/0x450 [ 4.343523] kthread+0xfc/0x184 [ 4.346669] ret_from_fork+0x10/0x20 [ 4.350256] Code: 2a0103f6 f81f83a8 9431ccd8 f9402688 (39434109) [ 4.356366] ---[ end trace 0000000000000000 ]--- I haven't looked at the code at all, but disassembling drivers/base/dd.lst, I think the NPD is at dev->p->dead (0xa68 + 0x3c = 0xaa4). 0000000000000a68 <__device_attach>: ; { a68: d503233f paciasp a6c: d10143ff sub sp, sp, #0x50 a70: a9027bfd stp x29, x30, [sp, #0x20] a74: a90357f6 stp x22, x21, [sp, #0x30] a78: a9044ff4 stp x20, x19, [sp, #0x40] a7c: 910083fd add x29, sp, #0x20 a80: d5384108 mrs x8, SP_EL0 ; mutex_lock(&dev->mutex); a84: 91020013 add x19, x0, #0x80 a88: f9423508 ldr x8, [x8, #0x468] a8c: aa0003f4 mov x20, x0 a90: aa1303e0 mov x0, x19 a94: 2a0103f6 mov w22, w1 a98: f81f83a8 stur x8, [x29, #-0x8] a9c: 94000000 bl 0xa9c <__device_attach+0x34> 0000000000000a9c: R_AARCH64_CALL26 mutex_lock ; if (dev->p->dead) { aa0: f9402688 ldr x8, [x20, #0x48] aa4: 39434109 ldrb w9, [x8, #0xd0] aa8: 37000129 tbnz w9, #0x0, 0xacc <__device_attach+0x64> ; } else if (dev->driver) { aac: f9403689 ldr x9, [x20, #0x68] ab0: b40003e9 cbz x9, 0xb2c <__device_attach+0xc4> ; return dev->p && klist_node_attached(&dev->p->knode_driver); ab4: b40002a8 cbz x8, 0xb08 <__device_attach+0xa0> ab8: 91012100 add x0, x8, #0x48 abc: 94000000 bl 0xabc <__device_attach+0x54> 0000000000000abc: R_AARCH64_CALL26 klist_node_attached ; if (device_is_bound(dev)) { ac0: 34000240 cbz w0, 0xb08 <__device_attach+0xa0> ac4: 52800035 mov w21, #0x1 ac8: 14000002 b 0xad0 <__device_attach+0x68> acc: 2a1f03f5 mov w21, wzr ; mutex_unlock(&dev->mutex); ad0: aa1303e0 mov x0, x19 ad4: 94000000 bl 0xad4 <__device_attach+0x6c> 0000000000000ad4: R_AARCH64_CALL26 mutex_unlock ad8: d5384108 mrs x8, SP_EL0 adc: f9423508 ldr x8, [x8, #0x468] ae0: f85f83a9 ldur x9, [x29, #-0x8] ae4: eb09011f cmp x8, x9 ae8: 540008c1 b.ne 0xc00 <__device_attach+0x198> ; return ret; aec: 2a1503e0 mov w0, w21 af0: a9444ff4 ldp x20, x19, [sp, #0x40] af4: a94357f6 ldp x22, x21, [sp, #0x30] af8: a9427bfd ldp x29, x30, [sp, #0x20] afc: 910143ff add sp, sp, #0x50 b00: d50323bf autiasp b04: d65f03c0 ret ; ret = driver_sysfs_add(dev); b08: aa1403e0 mov x0, x20 b0c: 97ffff21 bl 0x790 ; if (!ret) { b10: 340006c0 cbz w0, 0xbe8 <__device_attach+0x180> ; bus_notify(dev, BUS_NOTIFY_DRIVER_NOT_BOUND); b14: aa1403e0 mov x0, x20 b18: 528000e1 mov w1, #0x7 b1c: 94000000 bl 0xb1c <__device_attach+0xb4> 0000000000000b1c: R_AARCH64_CALL26 bus_notify b20: 2a1f03f5 mov w21, wzr ; dev->driver = NULL; b24: f900369f str xzr, [x20, #0x68] b28: 17ffffea b 0xad0 <__device_attach+0x68> b2c: 120002c8 and w8, w22, #0x1 ; if (dev->parent) b30: f9402280 ldr x0, [x20, #0x40] ; struct device_attach_data data = { b34: a900fff4 stp x20, xzr, [sp, #0x8] b38: 39004bff strb wzr, [sp, #0x12] b3c: 390043e8 strb w8, [sp, #0x10] ; if (dev->parent) b40: b4000060 cbz x0, 0xb4c <__device_attach+0xe4> ; return __pm_runtime_resume(dev, RPM_GET_PUT); b44: 52800081 mov w1, #0x4 b48: 94000000 bl 0xb48 <__device_attach+0xe0> 0000000000000b48: R_AARCH64_CALL26 __pm_runtime_resume ; ret = bus_for_each_drv(dev->bus, NULL, &data, b4c: f9403280 ldr x0, [x20, #0x60] b50: 90000003 adrp x3, 0x0 0000000000000b50: R_AARCH64_ADR_PREL_PG_HI21 .text+0x17ac b54: 91000063 add x3, x3, #0x0 0000000000000b54: R_AARCH64_ADD_ABS_LO12_NC .text+0x17ac b58: 910023e2 add x2, sp, #0x8 b5c: aa1f03e1 mov x1, xzr b60: 94000000 bl 0xb60 <__device_attach+0xf8> 0000000000000b60: R_AARCH64_CALL26 bus_for_each_drv b64: 39404be8 ldrb w8, [sp, #0x12] ; if (!ret && allow_async && data.have_async) { b68: 7100001f cmp w0, #0x0 b6c: 1a9f07e9 cset w9, ne ; ret = bus_for_each_drv(dev->bus, NULL, &data, b70: 2a0003f5 mov w21, w0 b74: 7100011f cmp w8, #0x0 ; if (!ret && allow_async && data.have_async) { b78: 520002c8 eor w8, w22, #0x1 b7c: 1a9f17ea cset w10, eq b80: 2a0a0108 orr w8, w8, w10 b84: 2a080136 orr w22, w9, w8 b88: 360000f6 tbz w22, #0x0, 0xba4 <__device_attach+0x13c> ; return __pm_runtime_idle(dev, RPM_ASYNC); b8c: aa1403e0 mov x0, x20 b90: 52800021 mov w1, #0x1 b94: 94000000 bl 0xb94 <__device_attach+0x12c> 0000000000000b94: R_AARCH64_CALL26 __pm_runtime_idle ; if (dev->parent) b98: f9402280 ldr x0, [x20, #0x40] b9c: b50000e0 cbnz x0, 0xbb8 <__device_attach+0x150> ba0: 14000008 b 0xbc0 <__device_attach+0x158> ; asm_volatile_goto( ba4: d503201f nop From fancer.lancer at gmail.com Tue Dec 5 22:14:34 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 14:14:34 +0300 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 10:45:34AM +0000, Russell King (Oracle) wrote: > On Tue, Dec 05, 2023 at 01:35:26PM +0300, Serge Semin wrote: > > Generic MDIO-device driver will support setting a custom device ID for the > > particular MDIO-device. > > Why future tense? I don't see anything later in this patch set adding > this. After the next patch is applied [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support the DW XPCS driver _will_ support setting custom IDs based on the platform data and the DT compatibles. It can be used for instance to fix the already available SJ1105 and SJ1110 MDIO bus implementations, so instead of substituting the XPCS IDs on the PHYSID CSR reads the driver could just pass the device ID and PMA ID via the device platform data. If my patch log text looks unclear anyway, just say so. I'll change it accordingly. I guess it would be enough to say that moving is required just to collect all the IDs in a single place. -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From tmaimon77 at gmail.com Tue Dec 5 22:18:22 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Tue, 5 Dec 2023 13:18:22 +0200 Subject: [PATCH v21] clk: npcm8xx: add clock controller Message-ID: <20231205111822.3036375-1-tmaimon77@gmail.com> Nuvoton Arbel BMC NPCM8XX contains an integrated clock controller which generates and supplies clocks to all modules within the BMC. Signed-off-by: Tomer Maimon Acked-by: Joel Stanley --- Addressed comments from: - Stephen Boyd : https://www.spinics.net/lists/kernel/msg5016941.html Changes since version 20: - Using regmap instead of ioremap. the clock and reset modules are sharing the same memory region and cause failure when using devm_platform_ioremap_resource function, this version uses regmap to handle shared reset and clock memory region, in case it is approved I will modify the reset driver to use the regmap as well. - Using clk_hw instead of clk_parent_data structre. - Divider clock definition to one line Changes since version 19: - Remove unnecessary free command. - Defining pr_fmt(). - Using dev_err_probe. - Return zero in the end of the probe function. Changes since version 18: - NPCM8XX clock driver did not changed from version 18 only build and tested under kernel 6.6-rc1. Changes since version 17: - NPCM8XX clock driver did not changed from version 17 only build and tested under kernel 6.5-rc3. Changes since version 16: - NPCM8XX clock driver - Using devm_kzalloc instead kzalloc. - Remove unnecessary parenthesis. - Modify incorrect spelling. Changes since version 15: - NPCM8XX clock driver - Remove unused regs parameter from npcm8xx_pll_data structure. - Using index and clk_hw parameters to set the clock parent in the clock structures. Changes since version 14: - NPCM8XX clock driver - Remove unnecessary register definitions. - Remove the internal reference clock, instead use the external DT reference clock. - rearrange the driver. - using .names parameter in DT to define clock (refclk). Changes since version 13: - NPCM8XX clock driver - Remove unnecessary definitions and add module.h define - Use in clk_parent_data struct.fw_name and .name. - Add module_exit function. - Add const to divider clock names. - Add MODULE_DESCRIPTION and MODULE_LICENSE Changes since version 12: - NPCM8XX clock driver - Use clk_parent_data in mux and div clock structure. - Add const to mux tables. - Using devm_clk_hw_register_fixed_rate function. - use only .name clk_parent_data instead .name and .fw_name. - Modify mask values in mux clocks. Changes since version 11: - NPCM8XX clock driver - Modify Kconfig help. - Modify loop variable to unsigned int. Changes since version 11: - NPCM8XX clock driver - Modify Kconfig help. - Modify loop variable to unsigned int. Changes since version 10: - NPCM8XX clock driver - Fix const warning. Changes since version 9: - NPCM8XX clock driver - Move configuration place. - Using clk_parent_data instead of parent_name - using devm_ioremap instead of ioremap. deeply sorry, I know we had a long discussion on what should the driver use, from other examples (also in other clock drivers) I see the combination of platform_get_resource and devm_ioremap are commonly used and it answer the reset and clock needs. Changes since version 8: - NPCM8XX clock driver - Move configuration place. - Add space before and aftre '{' '}'. - Handle devm_of_clk_add_hw_provider function error. Changes since version 7: - NPCM8XX clock driver - The clock and reset registers using the same memory region, due to it the clock driver should claim the ioremap directly without checking the memory region. Changes since version 5: - NPCM8XX clock driver - Remove refclk if devm_of_clk_add_hw_provider function failed. Changes since version 4: - NPCM8XX clock driver - Use the same quote in the dt-binding file. Changes since version 3: - NPCM8XX clock driver - Rename NPCM8xx clock dt-binding header file. - Remove unused structures. - Improve Handling the clocks registration. Changes since version 2: - NPCM8XX clock driver - Add debug new line. - Add 25M fixed rate clock. - Remove unused clocks and clock name from dt-binding. Changes since version 1: - NPCM8XX clock driver - Modify dt-binding. - Remove unsed definition and include. - Include alphabetically. - Use clock devm. drivers/clk/clk-npcm8xx.c | 552 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 552 insertions(+) create mode 100644 drivers/clk/clk-npcm8xx.c diff --git a/drivers/clk/clk-npcm8xx.c b/drivers/clk/clk-npcm8xx.c new file mode 100644 index 000000000000..e6c5111cc255 --- /dev/null +++ b/drivers/clk/clk-npcm8xx.c @@ -0,0 +1,552 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Nuvoton NPCM8xx Clock Generator + * All the clocks are initialized by the bootloader, so this driver allows only + * reading of current settings directly from the hardware. + * + * Copyright (C) 2020 Nuvoton Technologies + * Author: Tomer Maimon + */ + +#define pr_fmt(fmt) "npcm8xx_clk: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* npcm8xx clock registers*/ +#define NPCM8XX_CLKSEL 0x04 +#define NPCM8XX_CLKDIV1 0x08 +#define NPCM8XX_CLKDIV2 0x2C +#define NPCM8XX_CLKDIV3 0x58 +#define NPCM8XX_CLKDIV4 0x7C +#define NPCM8XX_PLLCON0 0x0C +#define NPCM8XX_PLLCON1 0x10 +#define NPCM8XX_PLLCON2 0x54 +#define NPCM8XX_PLLCONG 0x60 +#define NPCM8XX_THRTL_CNT 0xC0 + +#define PLLCON_LOKI BIT(31) +#define PLLCON_LOKS BIT(30) +#define PLLCON_FBDV GENMASK(27, 16) +#define PLLCON_OTDV2 GENMASK(15, 13) +#define PLLCON_PWDEN BIT(12) +#define PLLCON_OTDV1 GENMASK(10, 8) +#define PLLCON_INDV GENMASK(5, 0) + +struct npcm8xx_clk { + struct regmap *clk_regmap; + unsigned int offset; + const char *name; + const u32 *table; + u32 mask; + u8 shift; + unsigned long width; + unsigned long flags; + struct clk_hw hw; +}; + +#define to_npcm8xx_clk(_hw) container_of(_hw, struct npcm8xx_clk, hw) + +struct npcm8xx_clk_pll_data { + const char *name; + struct clk_parent_data parent; + unsigned int reg; + unsigned long flags; + struct clk_hw hw; +}; + +struct npcm8xx_clk_div_data { + u32 reg; + u8 shift; + u8 width; + const char *name; + const struct clk_hw *parent_hw; + unsigned long clk_divider_flags; + unsigned long flags; + int onecell_idx; + struct clk_hw hw; +}; + +struct npcm8xx_clk_mux_data { + u8 shift; + u32 mask; + const u32 *table; + const char *name; + const struct clk_parent_data *parent_data; + u8 num_parents; + unsigned long flags; + struct clk_hw hw; +}; + +/* external clock definition */ +#define NPCM8XX_CLK_S_REFCLK "refclk" + +/* pll definition */ +#define NPCM8XX_CLK_S_PLL0 "pll0" +#define NPCM8XX_CLK_S_PLL1 "pll1" +#define NPCM8XX_CLK_S_PLL2 "pll2" +#define NPCM8XX_CLK_S_PLL_GFX "pll_gfx" + +/* early divider definition */ +#define NPCM8XX_CLK_S_PLL2_DIV2 "pll2_div2" +#define NPCM8XX_CLK_S_PLL_GFX_DIV2 "pll_gfx_div2" +#define NPCM8XX_CLK_S_PLL1_DIV2 "pll1_div2" + +/* mux definition */ +#define NPCM8XX_CLK_S_CPU_MUX "cpu_mux" +#define NPCM8XX_CLK_S_PIX_MUX "gfx_pixel_mux" +#define NPCM8XX_CLK_S_SD_MUX "sd_mux" +#define NPCM8XX_CLK_S_UART_MUX "uart_mux" +#define NPCM8XX_CLK_S_SU_MUX "serial_usb_mux" +#define NPCM8XX_CLK_S_MC_MUX "mc_mux" +#define NPCM8XX_CLK_S_ADC_MUX "adc_mux" +#define NPCM8XX_CLK_S_GFX_MUX "gfx_mux" +#define NPCM8XX_CLK_S_CLKOUT_MUX "clkout_mux" +#define NPCM8XX_CLK_S_GFXM_MUX "gfxm_mux" +#define NPCM8XX_CLK_S_DVC_MUX "dvc_mux" +#define NPCM8XX_CLK_S_RG_MUX "rg_mux" +#define NPCM8XX_CLK_S_RCP_MUX "rcp_mux" + +/* div definition */ +#define NPCM8XX_CLK_S_MC "mc" +#define NPCM8XX_CLK_S_AXI "axi" +#define NPCM8XX_CLK_S_AHB "ahb" +#define NPCM8XX_CLK_S_SPI0 "spi0" +#define NPCM8XX_CLK_S_SPI1 "spi1" +#define NPCM8XX_CLK_S_SPI3 "spi3" +#define NPCM8XX_CLK_S_SPIX "spix" +#define NPCM8XX_CLK_S_APB1 "apb1" +#define NPCM8XX_CLK_S_APB2 "apb2" +#define NPCM8XX_CLK_S_APB3 "apb3" +#define NPCM8XX_CLK_S_APB4 "apb4" +#define NPCM8XX_CLK_S_APB5 "apb5" +#define NPCM8XX_CLK_S_APB19 "apb19" +#define NPCM8XX_CLK_S_TOCK "tock" +#define NPCM8XX_CLK_S_CLKOUT "clkout" +#define NPCM8XX_CLK_S_PRE_ADC "pre adc" +#define NPCM8XX_CLK_S_UART "uart" +#define NPCM8XX_CLK_S_UART2 "uart2" +#define NPCM8XX_CLK_S_TIMER "timer" +#define NPCM8XX_CLK_S_MMC "mmc" +#define NPCM8XX_CLK_S_SDHC "sdhc" +#define NPCM8XX_CLK_S_ADC "adc" +#define NPCM8XX_CLK_S_GFX "gfx0_gfx1_mem" +#define NPCM8XX_CLK_S_USBIF "serial_usbif" +#define NPCM8XX_CLK_S_USB_HOST "usb_host" +#define NPCM8XX_CLK_S_USB_BRIDGE "usb_bridge" +#define NPCM8XX_CLK_S_PCI "pci" +#define NPCM8XX_CLK_S_TH "th" +#define NPCM8XX_CLK_S_ATB "atb" +#define NPCM8XX_CLK_S_PRE_CLK "pre_clk" +#define NPCM8XX_CLK_S_RG "rg" +#define NPCM8XX_CLK_S_RCP "rcp" + +static struct clk_hw hw_pll1_div2, hw_pll2_div2, hw_gfx_div2, hw_pre_clk; +static struct npcm8xx_clk_pll_data npcm8xx_pll_clks[] = { + { NPCM8XX_CLK_S_PLL0, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON0, 0 }, + { NPCM8XX_CLK_S_PLL1, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON1, 0 }, + { NPCM8XX_CLK_S_PLL2, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON2, 0 }, + { NPCM8XX_CLK_S_PLL_GFX, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCONG, 0 }, +}; + +static const u32 cpuck_mux_table[] = { 0, 1, 2, 7 }; +static const struct clk_parent_data cpuck_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 }, + { .hw = &npcm8xx_pll_clks[2].hw } +}; + +static const u32 pixcksel_mux_table[] = { 0, 2 }; +static const struct clk_parent_data pixcksel_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[3].hw }, + { .index = 0 } +}; + +static const u32 default_mux_table[] = { 0, 1, 2, 3 }; +static const struct clk_parent_data default_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 }, + { .hw = &hw_pll2_div2 } +}; + +static const u32 sucksel_mux_table[] = { 2, 3 }; +static const struct clk_parent_data sucksel_mux_parents[] = { + { .index = 0 }, + { .hw = &hw_pll2_div2 } +}; + +static const u32 mccksel_mux_table[] = { 0, 2 }; +static const struct clk_parent_data mccksel_mux_parents[] = { + { .hw = &hw_pll1_div2 }, + { .index = 0 } +}; + +static const u32 clkoutsel_mux_table[] = { 0, 1, 2, 3, 4 }; +static const struct clk_parent_data clkoutsel_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 }, + { .hw = &hw_gfx_div2 }, + { .hw = &hw_pll2_div2 } +}; + +static const u32 gfxmsel_mux_table[] = { 2, 3 }; +static const struct clk_parent_data gfxmsel_mux_parents[] = { + { .index = 0 }, + { .hw = &npcm8xx_pll_clks[2].hw } +}; + +static const u32 dvcssel_mux_table[] = { 2, 3 }; +static const struct clk_parent_data dvcssel_mux_parents[] = { + { .index = 0 }, + { .hw = &npcm8xx_pll_clks[2].hw } +}; + +static const u32 default3_mux_table[] = { 0, 1, 2 }; +static const struct clk_parent_data default3_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 } +}; + +static struct npcm8xx_clk_mux_data npcm8xx_muxes[] = { + { 0, 7, cpuck_mux_table, NPCM8XX_CLK_S_CPU_MUX, cpuck_mux_parents, + ARRAY_SIZE(cpuck_mux_parents), CLK_IS_CRITICAL }, + { 4, 3, pixcksel_mux_table, NPCM8XX_CLK_S_PIX_MUX, pixcksel_mux_parents, + ARRAY_SIZE(pixcksel_mux_parents), 0 }, + { 6, 3, default_mux_table, NPCM8XX_CLK_S_SD_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 8, 3, default_mux_table, NPCM8XX_CLK_S_UART_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 10, 3, sucksel_mux_table, NPCM8XX_CLK_S_SU_MUX, sucksel_mux_parents, + ARRAY_SIZE(sucksel_mux_parents), 0 }, + { 12, 3, mccksel_mux_table, NPCM8XX_CLK_S_MC_MUX, mccksel_mux_parents, + ARRAY_SIZE(mccksel_mux_parents), 0 }, + { 14, 3, default_mux_table, NPCM8XX_CLK_S_ADC_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 16, 3, default_mux_table, NPCM8XX_CLK_S_GFX_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 18, 7, clkoutsel_mux_table, NPCM8XX_CLK_S_CLKOUT_MUX, clkoutsel_mux_parents, + ARRAY_SIZE(clkoutsel_mux_parents), 0 }, + { 21, 3, gfxmsel_mux_table, NPCM8XX_CLK_S_GFXM_MUX, gfxmsel_mux_parents, + ARRAY_SIZE(gfxmsel_mux_parents), 0 }, + { 23, 3, dvcssel_mux_table, NPCM8XX_CLK_S_DVC_MUX, dvcssel_mux_parents, + ARRAY_SIZE(dvcssel_mux_parents), 0 }, + { 25, 3, default3_mux_table, NPCM8XX_CLK_S_RG_MUX, default3_mux_parents, + ARRAY_SIZE(default3_mux_parents), 0 }, + { 27, 3, default3_mux_table, NPCM8XX_CLK_S_RCP_MUX, default3_mux_parents, + ARRAY_SIZE(default3_mux_parents), 0 }, +}; + +static struct npcm8xx_clk_div_data npcm8xx_pre_divs[] = { + { NPCM8XX_CLKDIV1, 21, 5, NPCM8XX_CLK_S_PRE_ADC, &npcm8xx_muxes[6].hw, CLK_DIVIDER_READ_ONLY, 0, -1 }, + { NPCM8XX_CLKDIV1, 26, 2, NPCM8XX_CLK_S_AHB, &hw_pre_clk, CLK_DIVIDER_READ_ONLY, CLK_IS_CRITICAL, NPCM8XX_CLK_AHB }, +}; + +/* configurable dividers: */ +static struct npcm8xx_clk_div_data npcm8xx_divs[] = { + { NPCM8XX_CLKDIV1, 28, 3, NPCM8XX_CLK_S_ADC, &npcm8xx_pre_divs[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_ADC }, + { NPCM8XX_CLKDIV1, 16, 5, NPCM8XX_CLK_S_UART, &npcm8xx_muxes[3].hw, 0, 0, NPCM8XX_CLK_UART }, + { NPCM8XX_CLKDIV1, 11, 5, NPCM8XX_CLK_S_MMC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_MMC }, + { NPCM8XX_CLKDIV1, 6, 5, NPCM8XX_CLK_S_SPI3, &npcm8xx_pre_divs[1].hw, 0, 0, NPCM8XX_CLK_SPI3 }, + { NPCM8XX_CLKDIV1, 2, 4, NPCM8XX_CLK_S_PCI, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_PCI }, + + { NPCM8XX_CLKDIV2, 30, 2, NPCM8XX_CLK_S_APB4, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB4 }, + { NPCM8XX_CLKDIV2, 28, 2, NPCM8XX_CLK_S_APB3, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB3 }, + { NPCM8XX_CLKDIV2, 26, 2, NPCM8XX_CLK_S_APB2, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB2 }, + { NPCM8XX_CLKDIV2, 24, 2, NPCM8XX_CLK_S_APB1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB1 }, + { NPCM8XX_CLKDIV2, 22, 2, NPCM8XX_CLK_S_APB5, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB5 }, + { NPCM8XX_CLKDIV2, 16, 5, NPCM8XX_CLK_S_CLKOUT, &npcm8xx_muxes[8].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_CLKOUT }, + { NPCM8XX_CLKDIV2, 13, 3, NPCM8XX_CLK_S_GFX, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_GFX }, + { NPCM8XX_CLKDIV2, 8, 5, NPCM8XX_CLK_S_USB_BRIDGE, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU }, + { NPCM8XX_CLKDIV2, 4, 4, NPCM8XX_CLK_S_USB_HOST, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU48 }, + { NPCM8XX_CLKDIV2, 0, 4, NPCM8XX_CLK_S_SDHC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SDHC }, + + { NPCM8XX_CLKDIV3, 16, 8, NPCM8XX_CLK_S_SPI1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI1 }, + { NPCM8XX_CLKDIV3, 11, 5, NPCM8XX_CLK_S_UART2, &npcm8xx_muxes[3].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_UART2 }, + { NPCM8XX_CLKDIV3, 6, 5, NPCM8XX_CLK_S_SPI0, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI0 }, + { NPCM8XX_CLKDIV3, 1, 5, NPCM8XX_CLK_S_SPIX, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPIX }, + + { NPCM8XX_CLKDIV4, 28, 4, NPCM8XX_CLK_S_RG, &npcm8xx_muxes[11].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RG }, + { NPCM8XX_CLKDIV4, 12, 4, NPCM8XX_CLK_S_RCP, &npcm8xx_muxes[12].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RCP }, + + { NPCM8XX_THRTL_CNT, 0, 2, NPCM8XX_CLK_S_TH, &npcm8xx_muxes[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_TH }, +}; + +static struct clk_hw * +npcm8xx_clk_register(struct device *dev, const char *name, + struct regmap *clk_regmap, unsigned int offset, + unsigned long flags, const struct clk_ops *npcm8xx_clk_ops, + const struct clk_parent_data *parent_data, + const struct clk_hw *parent_hw, u8 num_parents, + u8 shift, u32 mask, unsigned long width, + const u32 *table, unsigned long clk_flags) +{ + struct npcm8xx_clk *clk; + struct clk_init_data init = {}; + int ret; + + clk = devm_kzalloc(dev, sizeof(*clk), GFP_KERNEL); + if (!clk) + return ERR_PTR(-ENOMEM); + + init.name = name; + init.ops = npcm8xx_clk_ops; + init.parent_data = parent_data; + init.parent_hws = parent_hw ? &parent_hw : NULL; + init.num_parents = num_parents; + init.flags = flags; + + clk->clk_regmap = clk_regmap; + clk->hw.init = &init; + clk->offset = offset; + clk->shift = shift; + clk->mask = mask; + clk->width = width; + clk->table = table; + clk->flags = clk_flags; + + ret = devm_clk_hw_register(dev, &clk->hw); + if (ret) + return ERR_PTR(ret); + + return &clk->hw; +} + +static unsigned long npcm8xx_clk_pll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct npcm8xx_clk *pll = to_npcm8xx_clk(hw); + unsigned long fbdv, indv, otdv1, otdv2; + unsigned int val; + u64 ret; + + if (parent_rate == 0) { + pr_debug("%s: parent rate is zero\n", __func__); + return 0; + } + + regmap_read(pll->clk_regmap, pll->offset, &val); + + indv = FIELD_GET(PLLCON_INDV, val); + fbdv = FIELD_GET(PLLCON_FBDV, val); + otdv1 = FIELD_GET(PLLCON_OTDV1, val); + otdv2 = FIELD_GET(PLLCON_OTDV2, val); + + ret = (u64)parent_rate * fbdv; + do_div(ret, indv * otdv1 * otdv2); + + return ret; +} + +static const struct clk_ops npcm8xx_clk_pll_ops = { + .recalc_rate = npcm8xx_clk_pll_recalc_rate, +}; + +static u8 npcm8xx_clk_mux_get_parent(struct clk_hw *hw) +{ + struct npcm8xx_clk *mux = to_npcm8xx_clk(hw); + u32 val; + + regmap_read(mux->clk_regmap, mux->offset, &val); + val = val >> mux->shift; + val &= mux->mask; + + return clk_mux_val_to_index(hw, mux->table, mux->flags, val); +} + +static const struct clk_ops npcm8xx_clk_mux_ops = { + .get_parent = npcm8xx_clk_mux_get_parent, +}; + +static unsigned long npcm8xx_clk_div_get_parent(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct npcm8xx_clk *div = to_npcm8xx_clk(hw); + unsigned int val; + + regmap_read(div->clk_regmap, div->offset, &val); + val = val >> div->shift; + val &= clk_div_mask(div->width); + + return divider_recalc_rate(hw, parent_rate, val, NULL, div->flags, + div->width); +} + +static const struct clk_ops npcm8xx_clk_div_ops = { + .recalc_rate = npcm8xx_clk_div_get_parent, +}; + +static int npcm8xx_clk_probe(struct platform_device *pdev) +{ + struct clk_hw_onecell_data *npcm8xx_clk_data; + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct regmap *clk_regmap; + struct clk_hw *hw; + unsigned int i; + + npcm8xx_clk_data = devm_kzalloc(dev, struct_size(npcm8xx_clk_data, hws, + NPCM8XX_NUM_CLOCKS), + GFP_KERNEL); + if (!npcm8xx_clk_data) + return -ENOMEM; + + clk_regmap = syscon_regmap_lookup_by_phandle(np, "nuvoton,sysclk"); + if (IS_ERR(clk_regmap)) { + dev_err(&pdev->dev, "Failed to find nuvoton,sysclk\n"); + return PTR_ERR(clk_regmap); + } + + npcm8xx_clk_data->num = NPCM8XX_NUM_CLOCKS; + + for (i = 0; i < NPCM8XX_NUM_CLOCKS; i++) + npcm8xx_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); + + /* Register plls */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_pll_clks); i++) { + struct npcm8xx_clk_pll_data *pll_clk = &npcm8xx_pll_clks[i]; + + hw = npcm8xx_clk_register(dev, pll_clk->name, clk_regmap, + pll_clk->reg, pll_clk->flags, + &npcm8xx_clk_pll_ops, &pll_clk->parent, + NULL, 1, 0, 0, 0, NULL, 0); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pll\n"); + pll_clk->hw = *hw; + } + + /* Register fixed dividers */ + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PLL1_DIV2, + NPCM8XX_CLK_S_PLL1, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register fixed div\n"); + hw_pll1_div2 = *hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PLL2_DIV2, + NPCM8XX_CLK_S_PLL2, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pll2 div2\n"); + hw_pll2_div2 = *hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PLL_GFX_DIV2, + NPCM8XX_CLK_S_PLL_GFX, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register gfx div2\n"); + hw_gfx_div2 = *hw; + + /* Register muxes */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_muxes); i++) { + struct npcm8xx_clk_mux_data *mux_data = &npcm8xx_muxes[i]; + + hw = npcm8xx_clk_register(dev, mux_data->name, clk_regmap, + NPCM8XX_CLKSEL, mux_data->flags, + &npcm8xx_clk_mux_ops, + mux_data->parent_data, NULL, + mux_data->num_parents, + mux_data->shift, mux_data->mask, 0, + mux_data->table, 0); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register mux\n"); + mux_data->hw = *hw; + } + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PRE_CLK, + NPCM8XX_CLK_S_CPU_MUX, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pre clk div2\n"); + hw_pre_clk = *hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_AXI, + NPCM8XX_CLK_S_TH, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register axi div2\n"); + npcm8xx_clk_data->hws[NPCM8XX_CLK_AXI] = hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_ATB, + NPCM8XX_CLK_S_AXI, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register atb div2\n"); + npcm8xx_clk_data->hws[NPCM8XX_CLK_ATB] = hw; + + /* Register clock pre dividers specified in npcm8xx_divs */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_pre_divs); i++) { + struct npcm8xx_clk_div_data *div_data = &npcm8xx_pre_divs[i]; + + hw = npcm8xx_clk_register(dev, div_data->name, clk_regmap, + div_data->reg, div_data->flags, + &npcm8xx_clk_div_ops, NULL, + div_data->parent_hw, 1, + div_data->shift, 0, div_data->width, + NULL, div_data->clk_divider_flags); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pre div table\n"); + div_data->hw = *hw; + + if (div_data->onecell_idx >= 0) + npcm8xx_clk_data->hws[div_data->onecell_idx] = hw; + } + + /* Register clock dividers specified in npcm8xx_divs */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_divs); i++) { + struct npcm8xx_clk_div_data *div_data = &npcm8xx_divs[i]; + + hw = npcm8xx_clk_register(dev, div_data->name, clk_regmap, + div_data->reg, div_data->flags, + &npcm8xx_clk_div_ops, NULL, + div_data->parent_hw, 1, + div_data->shift, 0, div_data->width, + NULL, div_data->clk_divider_flags); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register div table\n"); + + if (div_data->onecell_idx >= 0) + npcm8xx_clk_data->hws[div_data->onecell_idx] = hw; + } + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, + npcm8xx_clk_data); +} + +static const struct of_device_id npcm8xx_clk_dt_ids[] = { + { .compatible = "nuvoton,npcm845-clk", }, + { } +}; +MODULE_DEVICE_TABLE(of, npcm8xx_clk_dt_ids); + +static struct platform_driver npcm8xx_clk_driver = { + .probe = npcm8xx_clk_probe, + .driver = { + .name = "npcm8xx_clk", + .of_match_table = npcm8xx_clk_dt_ids, + }, +}; + +static int __init npcm8xx_clk_driver_init(void) +{ + return platform_driver_register(&npcm8xx_clk_driver); +} +arch_initcall(npcm8xx_clk_driver_init); + +static void __exit npcm8xx_clk_exit(void) +{ + platform_driver_unregister(&npcm8xx_clk_driver); +} +module_exit(npcm8xx_clk_exit); + +MODULE_DESCRIPTION("Clock driver for Nuvoton NPCM8XX BMC SoC"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_LICENSE("GPL v2"); + -- 2.33.0 From linux at armlinux.org.uk Tue Dec 5 22:22:50 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 11:22:50 +0000 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 02:14:34PM +0300, Serge Semin wrote: > On Tue, Dec 05, 2023 at 10:45:34AM +0000, Russell King (Oracle) wrote: > > On Tue, Dec 05, 2023 at 01:35:26PM +0300, Serge Semin wrote: > > > Generic MDIO-device driver will support setting a custom device ID for the > > > particular MDIO-device. > > > > Why future tense? I don't see anything later in this patch set adding > > this. > > After the next patch is applied > [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support > the DW XPCS driver _will_ support setting custom IDs based on the > platform data and the DT compatibles. What is confusing is that the sentence makes it sound like it's some generic driver that can be used for any PCS, whereas in reality it is _this_ XPCS driver which is not generic. "This driver will support setting a custom device ID in a future patch." or explicitly state the summary line of the patch concerned so one can refer to it. Future references are difficult to find whether they're in email and especially once they're merged into git. > It can be used for instance to > fix the already available SJ1105 and SJ1110 MDIO bus implementations, > so instead of substituting the XPCS IDs on the PHYSID CSR reads the > driver could just pass the device ID and PMA ID via the device > platform data. > > If my patch log text looks unclear anyway, just say so. I'll change it > accordingly. I guess it would be enough to say that moving is required > just to collect all the IDs in a single place. You need to adjust your attitude - I did exactly that. There was something which I didn't understand, so I raised the issue. Sorry for spotting a problem, but do you always get arsey when a reviewer picks up on something wrong? If that's your attitude, then for this entire series: NAK. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From olteanv at gmail.com Tue Dec 5 22:24:29 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Tue, 5 Dec 2023 13:24:29 +0200 Subject: [PATCH net-next 01/16] net: pcs: xpcs: Drop sentinel entry from 2500basex ifaces list In-Reply-To: <20231205103559.9605-2-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-2-fancer.lancer@gmail.com> Message-ID: <20231205112429.bp6lpvj4klrfrrim@skbuf> On Tue, Dec 05, 2023 at 01:35:22PM +0300, Serge Semin wrote: > There are currently two methods (xpcs_find_compat() and > xpcs_get_interfaces()) defined in the driver which loop over the available > interfaces. All of them rely on the xpcs_compat.num_interfaces field value > to get the number of interfaces. That field is initialized with the > ARRAY_SIZE(xpcs_*_interfaces) macro function call. Thus the interface > arrays are supposed to be filled with actual interface IDs and there is no > need in the dummy terminating ID placed at the end of the arrays. Let's > drop the redundant PHY_INTERFACE_MODE_MAX entry from the > xpcs_2500basex_interfaces list and the redundant > PHY_INTERFACE_MODE_MAX-based conditional statement from the > xpcs_get_interfaces() method then. It would help the readability of the commit message if you would split it into multiple paragraphs. > > Signed-off-by: Serge Semin > --- Reviewed-by: Vladimir Oltean From olteanv at gmail.com Tue Dec 5 22:27:55 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Tue, 5 Dec 2023 13:27:55 +0200 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: <20231205103559.9605-6-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> Message-ID: <20231205112755.3am2mazwireflpkq@skbuf> On Tue, Dec 05, 2023 at 01:35:26PM +0300, Serge Semin wrote: > In addition to that having all supported DW XPCS device IDs defined in > a sinle place will improve the code maintainability and readability. single From fancer.lancer at gmail.com Tue Dec 5 22:31:41 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 14:31:41 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 10:49:47AM +0000, Russell King (Oracle) wrote: > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > or explicitly registered in the MDIO subsystem by means of the > > mdiobus_register_board_info() method there is no point in creating the > > dummy MDIO device instance in order to get the DW XPCS handler since the > > MDIO core subsystem will create the device during the MDIO bus > > registration procedure. > > Please reword this overly long sentence. Ok. > > If they're left unmasked, what prevents them being created as PHY > devices? Not sure I fully get what you meant. If they are left unmasked the MDIO-device descriptor will be created by the MDIO subsystem anyway. What the point in creating another one? > > > @@ -1437,19 +1435,21 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, > > struct mdio_device *mdiodev; > > struct dw_xpcs *xpcs; > > > > - mdiodev = mdio_device_create(bus, addr); > > - if (IS_ERR(mdiodev)) > > - return ERR_CAST(mdiodev); > > + if (addr >= PHY_MAX_ADDR) > > + return ERR_PTR(-EINVAL); > > > > - xpcs = xpcs_create(mdiodev, interface); > > + if (mdiobus_is_registered_device(bus, addr)) { > > + mdiodev = bus->mdio_map[addr]; > > + mdio_device_get(mdiodev); > > No, this makes no sense now. This function is called > xpcs_create_mdiodev() - note the "create_mdiodev" part. If it's getting > the mdiodev from what is already there then it isn't creating it, so > it's no longer doing what it says in its function name. If you want to > add this functionality, create a new function to do it. AFAICS the method semantics is a bit different. It's responsibility is to create the DW XPCS descriptor. MDIO-device is utilized internally by the DW XPCS driver. The function callers don't access the created MDIO device directly (at least since some recent commit). So AFAIU "create" means creating the XPCS descriptor irrespective from the internal communication layer. So IMO the suffix is a bit misleading. I'll change it in one of the next commit anyway. Should I just merge that patch back in this one? -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From fancer.lancer at gmail.com Tue Dec 5 22:35:46 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 14:35:46 +0300 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: <20231205111351.xjjuwpbf7kwg3vuh@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> Message-ID: Hi Vladimir On Tue, Dec 05, 2023 at 01:13:51PM +0200, Vladimir Oltean wrote: > On Tue, Dec 05, 2023 at 01:35:31PM +0300, Serge Semin wrote: > > @@ -1436,21 +1480,32 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > > struct dw_xpcs *xpcs; > > int ret; > > > > + ret = device_attach(&mdiodev->dev); > > + if (ret < 0 && ret != -ENODEV) > > + return ERR_PTR(ret); > > + > > xpcs = xpcs_create_data(mdiodev); > > if (IS_ERR(xpcs)) > > return xpcs; > > > > + ret = xpcs_init_clks(xpcs); > > + if (ret) > > + goto out_free_data; > > + > > ret = xpcs_init_id(xpcs); > > if (ret) > > - goto out; > > + goto out_clear_clks; > > > > ret = xpcs_init_iface(xpcs, interface); > > if (ret) > > - goto out; > > + goto out_clear_clks; > > > > return xpcs; > > [ 4.083518] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000d0 > [ 4.092356] Mem abort info: > [ 4.095164] ESR = 0x0000000096000004 > [ 4.098932] EC = 0x25: DABT (current EL), IL = 32 bits > [ 4.104277] SET = 0, FnV = 0 > [ 4.107352] EA = 0, S1PTW = 0 > [ 4.110505] FSC = 0x04: level 0 translation fault > [ 4.115408] Data abort info: > [ 4.118296] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 > [ 4.123807] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 > [ 4.128877] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 > [ 4.134214] [00000000000000d0] user address but active_mm is swapper > [ 4.140595] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP > [ 4.146882] Modules linked in: > [ 4.149944] CPU: 0 PID: 11 Comm: kworker/u4:0 Not tainted 6.7.0-rc3-00719-g75be5ea8e111-dirty #1551 > [ 4.164524] Workqueue: events_unbound deferred_probe_work_func > [ 4.177372] pc : __device_attach+0x3c/0x1bc > [ 4.181570] lr : __device_attach+0x38/0x1bc > [ 4.185767] sp : ffff8000800f3800 > [ 4.189087] x29: ffff8000800f3820 x28: 0000000000000001 x27: ffff063781bda150 > [ 4.196252] x26: ffff063781bda150 x25: ffff063780827480 x24: ffffcb9a08138a40 > [ 4.203416] x23: ffff063781114080 x22: 0000000000000000 x21: 0000000000000004 > [ 4.210579] x20: ffff06378123a400 x19: ffff06378123a480 x18: ffffcb9a07c703a0 > [ 4.217743] x17: ffffcb9a07c703a4 x16: 00000000000000d4 x15: ffffcb9a07be70fc > [ 4.224906] x14: ffffcb9a08299638 x13: 0000000000000053 x12: ffff003000000200 > [ 4.232069] x11: 0000000000000000 x10: 0000000000000000 x9 : 0000000000000000 > [ 4.239233] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 000000000000003a > [ 4.246396] x5 : ffff0637809a037b x4 : ffffcb9a087b0d47 x3 : ffff10300000020f > [ 4.253560] x2 : ffffcb9a0910c561 x1 : 0000000000000000 x0 : ffff06378123a480 > [ 4.260724] Call trace: > [ 4.263172] __device_attach+0x3c/0x1bc > [ 4.267020] device_attach+0x14/0x20 > [ 4.270606] xpcs_create+0x24/0x384 > [ 4.274107] xpcs_create_byaddr+0x74/0xa0 > [ 4.278129] sja1105_mdiobus_register+0xf8/0x478 > [ 4.282763] sja1105_setup+0xb4/0x1194 > [ 4.286524] dsa_register_switch+0xab0/0x11f8 > [ 4.290895] sja1105_probe+0x2bc/0x2e4 > [ 4.294654] spi_probe+0xa4/0xc4 > [ 4.297890] really_probe+0x16c/0x3fc > [ 4.301564] __driver_probe_device+0xa4/0x168 > [ 4.305935] driver_probe_device+0x3c/0x220 > [ 4.310131] __device_attach_driver+0x128/0x1cc > [ 4.314676] bus_for_each_drv+0xf4/0x14c > [ 4.318610] __device_attach+0xfc/0x1bc > [ 4.322457] device_initial_probe+0x14/0x20 > [ 4.326654] bus_probe_device+0x94/0x100 > [ 4.330587] deferred_probe_work_func+0xa0/0xfc > [ 4.335132] process_scheduled_works+0x210/0x318 > [ 4.339764] worker_thread+0x28c/0x450 > [ 4.343523] kthread+0xfc/0x184 > [ 4.346669] ret_from_fork+0x10/0x20 > [ 4.350256] Code: 2a0103f6 f81f83a8 9431ccd8 f9402688 (39434109) > [ 4.356366] ---[ end trace 0000000000000000 ]--- > > I haven't looked at the code at all, but disassembling drivers/base/dd.lst, > I think the NPD is at dev->p->dead (0xa68 + 0x3c = 0xaa4). > > 0000000000000a68 <__device_attach>: > ; { > a68: d503233f paciasp > a6c: d10143ff sub sp, sp, #0x50 > a70: a9027bfd stp x29, x30, [sp, #0x20] > a74: a90357f6 stp x22, x21, [sp, #0x30] > a78: a9044ff4 stp x20, x19, [sp, #0x40] > a7c: 910083fd add x29, sp, #0x20 > a80: d5384108 mrs x8, SP_EL0 > ; mutex_lock(&dev->mutex); > a84: 91020013 add x19, x0, #0x80 > a88: f9423508 ldr x8, [x8, #0x468] > a8c: aa0003f4 mov x20, x0 > a90: aa1303e0 mov x0, x19 > a94: 2a0103f6 mov w22, w1 > a98: f81f83a8 stur x8, [x29, #-0x8] > a9c: 94000000 bl 0xa9c <__device_attach+0x34> > 0000000000000a9c: R_AARCH64_CALL26 mutex_lock > ; if (dev->p->dead) { > aa0: f9402688 ldr x8, [x20, #0x48] > aa4: 39434109 ldrb w9, [x8, #0xd0] > aa8: 37000129 tbnz w9, #0x0, 0xacc <__device_attach+0x64> > ; } else if (dev->driver) { > aac: f9403689 ldr x9, [x20, #0x68] > ab0: b40003e9 cbz x9, 0xb2c <__device_attach+0xc4> > ; return dev->p && klist_node_attached(&dev->p->knode_driver); > ab4: b40002a8 cbz x8, 0xb08 <__device_attach+0xa0> > ab8: 91012100 add x0, x8, #0x48 > abc: 94000000 bl 0xabc <__device_attach+0x54> > 0000000000000abc: R_AARCH64_CALL26 klist_node_attached > ; if (device_is_bound(dev)) { > ac0: 34000240 cbz w0, 0xb08 <__device_attach+0xa0> > ac4: 52800035 mov w21, #0x1 > ac8: 14000002 b 0xad0 <__device_attach+0x68> > acc: 2a1f03f5 mov w21, wzr > ; mutex_unlock(&dev->mutex); > ad0: aa1303e0 mov x0, x19 > ad4: 94000000 bl 0xad4 <__device_attach+0x6c> > 0000000000000ad4: R_AARCH64_CALL26 mutex_unlock > ad8: d5384108 mrs x8, SP_EL0 > adc: f9423508 ldr x8, [x8, #0x468] > ae0: f85f83a9 ldur x9, [x29, #-0x8] > ae4: eb09011f cmp x8, x9 > ae8: 540008c1 b.ne 0xc00 <__device_attach+0x198> > ; return ret; > aec: 2a1503e0 mov w0, w21 > af0: a9444ff4 ldp x20, x19, [sp, #0x40] > af4: a94357f6 ldp x22, x21, [sp, #0x30] > af8: a9427bfd ldp x29, x30, [sp, #0x20] > afc: 910143ff add sp, sp, #0x50 > b00: d50323bf autiasp > b04: d65f03c0 ret > ; ret = driver_sysfs_add(dev); > b08: aa1403e0 mov x0, x20 > b0c: 97ffff21 bl 0x790 > ; if (!ret) { > b10: 340006c0 cbz w0, 0xbe8 <__device_attach+0x180> > ; bus_notify(dev, BUS_NOTIFY_DRIVER_NOT_BOUND); > b14: aa1403e0 mov x0, x20 > b18: 528000e1 mov w1, #0x7 > b1c: 94000000 bl 0xb1c <__device_attach+0xb4> > 0000000000000b1c: R_AARCH64_CALL26 bus_notify > b20: 2a1f03f5 mov w21, wzr > ; dev->driver = NULL; > b24: f900369f str xzr, [x20, #0x68] > b28: 17ffffea b 0xad0 <__device_attach+0x68> > b2c: 120002c8 and w8, w22, #0x1 > ; if (dev->parent) > b30: f9402280 ldr x0, [x20, #0x40] > ; struct device_attach_data data = { > b34: a900fff4 stp x20, xzr, [sp, #0x8] > b38: 39004bff strb wzr, [sp, #0x12] > b3c: 390043e8 strb w8, [sp, #0x10] > ; if (dev->parent) > b40: b4000060 cbz x0, 0xb4c <__device_attach+0xe4> > ; return __pm_runtime_resume(dev, RPM_GET_PUT); > b44: 52800081 mov w1, #0x4 > b48: 94000000 bl 0xb48 <__device_attach+0xe0> > 0000000000000b48: R_AARCH64_CALL26 __pm_runtime_resume > ; ret = bus_for_each_drv(dev->bus, NULL, &data, > b4c: f9403280 ldr x0, [x20, #0x60] > b50: 90000003 adrp x3, 0x0 > 0000000000000b50: R_AARCH64_ADR_PREL_PG_HI21 .text+0x17ac > b54: 91000063 add x3, x3, #0x0 > 0000000000000b54: R_AARCH64_ADD_ABS_LO12_NC .text+0x17ac > b58: 910023e2 add x2, sp, #0x8 > b5c: aa1f03e1 mov x1, xzr > b60: 94000000 bl 0xb60 <__device_attach+0xf8> > 0000000000000b60: R_AARCH64_CALL26 bus_for_each_drv > b64: 39404be8 ldrb w8, [sp, #0x12] > ; if (!ret && allow_async && data.have_async) { > b68: 7100001f cmp w0, #0x0 > b6c: 1a9f07e9 cset w9, ne > ; ret = bus_for_each_drv(dev->bus, NULL, &data, > b70: 2a0003f5 mov w21, w0 > b74: 7100011f cmp w8, #0x0 > ; if (!ret && allow_async && data.have_async) { > b78: 520002c8 eor w8, w22, #0x1 > b7c: 1a9f17ea cset w10, eq > b80: 2a0a0108 orr w8, w8, w10 > b84: 2a080136 orr w22, w9, w8 > b88: 360000f6 tbz w22, #0x0, 0xba4 <__device_attach+0x13c> > ; return __pm_runtime_idle(dev, RPM_ASYNC); > b8c: aa1403e0 mov x0, x20 > b90: 52800021 mov w1, #0x1 > b94: 94000000 bl 0xb94 <__device_attach+0x12c> > 0000000000000b94: R_AARCH64_CALL26 __pm_runtime_idle > ; if (dev->parent) > b98: f9402280 ldr x0, [x20, #0x40] > b9c: b50000e0 cbnz x0, 0xbb8 <__device_attach+0x150> > ba0: 14000008 b 0xbc0 <__device_attach+0x158> > ; asm_volatile_goto( > ba4: d503201f nop Omg, thank you very much for testing the series straight away and sorry for the immediate trouble it caused. I'll need some more time for investigation. I'll get back to this topic a bit later on this week. -Serge(y) From fancer.lancer at gmail.com Tue Dec 5 22:39:22 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 14:39:22 +0300 Subject: [PATCH net-next 01/16] net: pcs: xpcs: Drop sentinel entry from 2500basex ifaces list In-Reply-To: <20231205112429.bp6lpvj4klrfrrim@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-2-fancer.lancer@gmail.com> <20231205112429.bp6lpvj4klrfrrim@skbuf> Message-ID: On Tue, Dec 05, 2023 at 01:24:29PM +0200, Vladimir Oltean wrote: > On Tue, Dec 05, 2023 at 01:35:22PM +0300, Serge Semin wrote: > > There are currently two methods (xpcs_find_compat() and > > xpcs_get_interfaces()) defined in the driver which loop over the available > > interfaces. All of them rely on the xpcs_compat.num_interfaces field value > > to get the number of interfaces. That field is initialized with the > > ARRAY_SIZE(xpcs_*_interfaces) macro function call. Thus the interface > > arrays are supposed to be filled with actual interface IDs and there is no > > need in the dummy terminating ID placed at the end of the arrays. Let's > > drop the redundant PHY_INTERFACE_MODE_MAX entry from the > > xpcs_2500basex_interfaces list and the redundant > > PHY_INTERFACE_MODE_MAX-based conditional statement from the > > xpcs_get_interfaces() method then. > > It would help the readability of the commit message if you would split > it into multiple paragraphs. Yeah, creating sometimes overcomplicated log messages is my eternal problem.) Ok. I'll split it up. > > > > > Signed-off-by: Serge Semin > > --- > > Reviewed-by: Vladimir Oltean Thanks. -Serge(y) From fancer.lancer at gmail.com Tue Dec 5 22:48:25 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 14:48:25 +0300 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 11:22:50AM +0000, Russell King (Oracle) wrote: > On Tue, Dec 05, 2023 at 02:14:34PM +0300, Serge Semin wrote: > > On Tue, Dec 05, 2023 at 10:45:34AM +0000, Russell King (Oracle) wrote: > > > On Tue, Dec 05, 2023 at 01:35:26PM +0300, Serge Semin wrote: > > > > Generic MDIO-device driver will support setting a custom device ID for the > > > > particular MDIO-device. > > > > > > Why future tense? I don't see anything later in this patch set adding > > > this. > > > > After the next patch is applied > > [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support > > the DW XPCS driver _will_ support setting custom IDs based on the > > platform data and the DT compatibles. > > What is confusing is that the sentence makes it sound like it's some > generic driver that can be used for any PCS, whereas in reality it is > _this_ XPCS driver which is not generic. > > "This driver will support setting a custom device ID in a future patch." > or explicitly state the summary line of the patch concerned so one can > refer to it. Future references are difficult to find whether they're in > email and especially once they're merged into git. Ok. I'll convert the patch log to be less confusing. As I already said to Vladimir writing sometimes overcomplicated messages my eternal problem. > > > It can be used for instance to > > fix the already available SJ1105 and SJ1110 MDIO bus implementations, > > so instead of substituting the XPCS IDs on the PHYSID CSR reads the > > driver could just pass the device ID and PMA ID via the device > > platform data. > > > > If my patch log text looks unclear anyway, just say so. I'll change it > > accordingly. I guess it would be enough to say that moving is required > > just to collect all the IDs in a single place. > > You need to adjust your attitude - I did exactly that. There was > something which I didn't understand, so I raised the issue. Sorry > for spotting a problem, but do you always get arsey when a reviewer > picks up on something wrong? If that's your attitude, then for this > entire series: NAK. I'm sorry if what I wrote sounded like I was arsey. I didn't mean it at all, really. By this sentence: > I guess it would be enough to say that moving is required > just to collect all the IDs in a single place. I meant that _I_ should have just stated in the log message that moving was required to collect all the IDs in a single place. The rest of the text was redundant and caused confusion what you pointed out to. -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From fancer.lancer at gmail.com Tue Dec 5 22:49:41 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 5 Dec 2023 14:49:41 +0300 Subject: [PATCH net-next 05/16] net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h In-Reply-To: <20231205112755.3am2mazwireflpkq@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> <20231205103559.9605-6-fancer.lancer@gmail.com> <20231205112755.3am2mazwireflpkq@skbuf> Message-ID: <6zejbbv6oriaztbbgyjy6r6hycccq6rvypb5ywxf7nqx3vlq7r@na5eossdsuec> On Tue, Dec 05, 2023 at 01:27:55PM +0200, Vladimir Oltean wrote: > On Tue, Dec 05, 2023 at 01:35:26PM +0300, Serge Semin wrote: > > In addition to that having all supported DW XPCS device IDs defined in > > a sinle place will improve the code maintainability and readability. > > single Got it. Thanks. Seeing there are so many comments about the log messages I'll double check them on v2. -Serge(y) From olteanv at gmail.com Tue Dec 5 22:52:34 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Tue, 5 Dec 2023 13:52:34 +0200 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: <20231205115234.7ntjvymurot5nnak@skbuf> On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > or explicitly registered in the MDIO subsystem by means of the > mdiobus_register_board_info() method mdiobus_register_board_info() has exactly one caller, and that is dsa_loop. I don't understand the relevance of it w.r.t. Synopsys XPCS. I'm reading the patches in order from the beginning. > there is no point in creating the dummy MDIO device instance in order Why dummy? There's nothing dummy about the mdio_device. It's how the PCS code accesses the hardware. > to get the DW XPCS handler since the MDIO core subsystem will create > the device during the MDIO bus registration procedure. It won't, though? Unless someone is using mdiobus_register_board_info() possibly, but who does that? > All what needs to be done is to just reuse the MDIO-device instance > available in the mii_bus.mdio_map array (using some getter for it > would look better though). It shall prevent the XPCS devices been > accessed over several MDIO-device instances. > > Note since the MDIO-device instance might be retrieved from the MDIO-bus > map array its reference counter shall be increased. If the MDIO-device > instance is created in the xpcs_create_mdiodev() method its reference > counter will be already increased. So there is no point in toggling the > reference counter in the xpcs_create() function. Just drop it from there. > > Signed-off-by: Serge Semin > --- Sorry, because the commit log lost me at the "context presentation" stage, I failed to understand the "what"s and the "why"s. Are you basically trying to add xpcs support on top of an mdio_device where the mdio_device_create() call was made externally to the xpcs code, through mdiobus_register_board_info() and mdiobus_setup_mdiodev_from_board_info()? From olteanv at gmail.com Tue Dec 5 23:23:16 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Tue, 5 Dec 2023 14:23:16 +0200 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> Message-ID: <20231205122316.ihhpklv222f5giz3@skbuf> On Tue, Dec 05, 2023 at 02:35:46PM +0300, Serge Semin wrote: > Omg, thank you very much for testing the series straight away and > sorry for the immediate trouble it caused. I'll need some more time > for investigation. I'll get back to this topic a bit later on this > week. Don't worry, I got suspicious when I was CCed to review only a one-line change in patch 11/16. It's never about that one line, is it?) Anyway, the NULL dev->p is a symptom of device_add() not having been called, most likely from mdio_device_register(). I'll be honest and say that I still don't quite understand what you're trying to achieve. You're trying to bind the hardcoded mdio_devices created by xpcs_create() to a driver? That was attempted a while ago by Sean Anderson with the Lynx PCS. Are you aware of the fact that even in the good case in which binding the driver actually works, the user can then come along and unbind it from the PCS device, and phylink isn't prepared to handle that, so it will crash the kernel upon the next phylink_pcs call? The pcs-rzn1-miic.c driver puts a device_link to the MAC to at least tear down the whole thing when the PCS is unbound, which is saner than crashing the kernel. I don't see the equivalent protection mechanism here? Can't the xpcs continue to live without a bound driver? Having a compatible string in the OF description is perfectly fine though, and should absolutely not preclude that. From linux at armlinux.org.uk Wed Dec 6 00:31:03 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 13:31:03 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 02:31:41PM +0300, Serge Semin wrote: > On Tue, Dec 05, 2023 at 10:49:47AM +0000, Russell King (Oracle) wrote: > > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > > or explicitly registered in the MDIO subsystem by means of the > > > mdiobus_register_board_info() method there is no point in creating the > > > dummy MDIO device instance in order to get the DW XPCS handler since the > > > MDIO core subsystem will create the device during the MDIO bus > > > registration procedure. > > > > > Please reword this overly long sentence. > > Ok. > > > > > If they're left unmasked, what prevents them being created as PHY > > devices? > > Not sure I fully get what you meant. If they are left unmasked the > MDIO-device descriptor will be created by the MDIO subsystem anyway. > What the point in creating another one? The MDIO bus scan looks for devices on the MDIO bus by probing each address. If it finds a response, it creates a PHY device (struct phy_device), and stores a pointer to the mdiodev embedded in this structure in the array. This device then gets registered as a PHY device, and becomes available for use by phylib and PHY drivers. This is something that needs to be avoided, but I don't see anything in your series that achieves that. > > No, this makes no sense now. This function is called > > xpcs_create_mdiodev() - note the "create_mdiodev" part. If it's getting > > the mdiodev from what is already there then it isn't creating it, so > > it's no longer doing what it says in its function name. If you want to > > add this functionality, create a new function to do it. > > AFAICS the method semantics is a bit different. It's responsibility is to > create the DW XPCS descriptor. MDIO-device is utilized internally by > the DW XPCS driver. The function callers don't access the created MDIO > device directly (at least since some recent commit). So AFAIU "create" > means creating the XPCS descriptor irrespective from the internal > communication layer. So IMO the suffix is a bit misleading. I'll > change it in one of the next commit anyway. Should I just merge that > patch back in this one? This function was created (by me) to also create the mdiodev. The function for use with a pre-existing mdiodev was xpcs_create(). But what do I know, I was only the author of this function, and of course you're correct. I don't like this patch anyway. Moving the mdio_device_get() etc out of xpcs_create() is wrong. Even if you get a mdiodev from some other place, then having xpcs_create() take a reference on it is still the correct thing to do. My conclusion is you don't understand refcounting. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From andrew at lunn.ch Wed Dec 6 00:34:32 2023 From: andrew at lunn.ch (Andrew Lunn) Date: Tue, 5 Dec 2023 14:34:32 +0100 Subject: [PATCH net-next 03/16] net: pcs: xpcs: Return EINVAL in the internal methods In-Reply-To: <20231205103559.9605-4-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-4-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 01:35:24PM +0300, Serge Semin wrote: > In particular the xpcs_soft_reset() and xpcs_do_config() functions > currently return -1 if invalid auto-negotiation mode is specified. That > value can be then passed to the generic kernel subsystems which require a > standard kernel errno value. Even though the error conditions are very > specific (memory corruption or buggy implementation) using a hard-coded -1 > literal doesn't seem correct anyway. > > Signed-off-by: Serge Semin Tested-by: Andrew Lunn Andrew From andrew at lunn.ch Wed Dec 6 00:34:21 2023 From: andrew at lunn.ch (Andrew Lunn) Date: Tue, 5 Dec 2023 14:34:21 +0100 Subject: [PATCH net-next 02/16] net: pcs: xpcs: Drop redundant workqueue.h include directive In-Reply-To: <20231205103559.9605-3-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-3-fancer.lancer@gmail.com> Message-ID: <5bdff6e8-40ae-4273-ad84-254bdc04433a@lunn.ch> On Tue, Dec 05, 2023 at 01:35:23PM +0300, Serge Semin wrote: > There is nothing CM workqueue-related in the driver. So the respective > include directive can be dropped. > > While at it add an empty line delimiter between the generic and local path > include directives. > > Signed-off-by: Serge Semin Tested-by: Andrew Lunn Andrew From linux at armlinux.org.uk Wed Dec 6 00:46:44 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 13:46:44 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: <20231205103559.9605-7-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > or explicitly registered in the MDIO subsystem by means of the > mdiobus_register_board_info() method there is no point in creating the > dummy MDIO device instance in order to get the DW XPCS handler since the > MDIO core subsystem will create the device during the MDIO bus > registration procedure. All what needs to be done is to just reuse the > MDIO-device instance available in the mii_bus.mdio_map array (using some > getter for it would look better though). It shall prevent the XPCS devices > been accessed over several MDIO-device instances. > > Note since the MDIO-device instance might be retrieved from the MDIO-bus > map array its reference counter shall be increased. If the MDIO-device > instance is created in the xpcs_create_mdiodev() method its reference > counter will be already increased. So there is no point in toggling the > reference counter in the xpcs_create() function. Just drop it from there. > > Signed-off-by: Serge Semin > --- > drivers/net/pcs/pcs-xpcs.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c > index 2850122f354a..a53376472394 100644 > --- a/drivers/net/pcs/pcs-xpcs.c > +++ b/drivers/net/pcs/pcs-xpcs.c > @@ -1376,7 +1376,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > if (!xpcs) > return ERR_PTR(-ENOMEM); > > - mdio_device_get(mdiodev); > xpcs->mdiodev = mdiodev; > > xpcs_id = xpcs_get_id(xpcs); > @@ -1417,7 +1416,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > ret = -ENODEV; > > out: > - mdio_device_put(mdiodev); > kfree(xpcs); > > return ERR_PTR(ret); The above two hunks are a completely Unnecessary change. > @@ -1437,19 +1435,21 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, > struct mdio_device *mdiodev; > struct dw_xpcs *xpcs; > > - mdiodev = mdio_device_create(bus, addr); > - if (IS_ERR(mdiodev)) > - return ERR_CAST(mdiodev); > + if (addr >= PHY_MAX_ADDR) > + return ERR_PTR(-EINVAL); > > - xpcs = xpcs_create(mdiodev, interface); > + if (mdiobus_is_registered_device(bus, addr)) { > + mdiodev = bus->mdio_map[addr]; > + mdio_device_get(mdiodev); This is fine - taking a reference on the mdiodev you've got from somewhere else is the right thing to do. > + } else { > + mdiodev = mdio_device_create(bus, addr); > + if (IS_ERR(mdiodev)) > + return ERR_CAST(mdiodev); > + } > > - /* xpcs_create() has taken a refcount on the mdiodev if it was > - * successful. If xpcs_create() fails, this will free the mdio > - * device here. In any case, we don't need to hold our reference > - * anymore, and putting it here will allow mdio_device_put() in > - * xpcs_destroy() to automatically free the mdio device. > - */ > - mdio_device_put(mdiodev); > + xpcs = xpcs_create(mdiodev, interface); > + if (IS_ERR(xpcs)) > + mdio_device_put(mdiodev); Without the change to xpcs_create() you don't need this change - and this is why I say you don't understand refcounting. The point here is that the refcounting management is in each function where references are gained or lost. xpcs_create() creates a new reference to the mdiodev by storing it in the dw_xpcs structure. Therefore, it takes a reference to the mdiodev. If something fails, it drops that reference to restore the refcount as it was on function entry. xpcs_create_mdiodev() as it originally stood creates the mdiodev from the bus/address, and then passes that to xpcs_create(). Once xpcs_create() has finished its work (irrespective of whether it was successful or not) we're done with the mdiodev in this function, so the reference is _always_ put. For your use case, it would be: mdiodev = bus->mdio_map[addr]; mdio_device_get(mdiodev); xpcs = xpcs_create(mdiodev, interface); mdio_device_put(mdiodev); return xpcs; which illustrates this point - we get a reference to the mdiodev by reading it from the array. We do something (calling xpcs_create) with it. If that something was successful, it takes its own refcount otherwise leaves it as-is. We're then done with the mdiodev so we drop the refcount we took. There is no need to make the code more complicated by changing this, so I regard the refcount changes in this patch to be wrong. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From andrew at lunn.ch Wed Dec 6 00:52:24 2023 From: andrew at lunn.ch (Andrew Lunn) Date: Tue, 5 Dec 2023 14:52:24 +0100 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 02:31:41PM +0300, Serge Semin wrote: > On Tue, Dec 05, 2023 at 10:49:47AM +0000, Russell King (Oracle) wrote: > > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > > or explicitly registered in the MDIO subsystem by means of the > > > mdiobus_register_board_info() method there is no point in creating the > > > dummy MDIO device instance in order to get the DW XPCS handler since the > > > MDIO core subsystem will create the device during the MDIO bus > > > registration procedure. > > > > > Please reword this overly long sentence. > > Ok. > > > > > If they're left unmasked, what prevents them being created as PHY > > devices? > > Not sure I fully get what you meant. If they are left unmasked the > MDIO-device descriptor will be created by the MDIO subsystem anyway. > What the point in creating another one? Saying what Russell said, in a different way: /* * Return true if the child node is for a phy. It must either: * o Compatible string of "ethernet-phy-idX.X" * o Compatible string of "ethernet-phy-ieee802.3-c45" * o Compatible string of "ethernet-phy-ieee802.3-c22" * o In the white list above (and issue a warning) * o No compatibility string * * A device which is not a phy is expected to have a compatible string * indicating what sort of device it is. */ bool of_mdiobus_child_is_phy(struct device_node *child) So when walking the bus, if a node is found which fits these criteria, its assumed to be a PHY. Anything on the MDIO bus which is not a PHY needs to use a compatible. Andrew From lkp at intel.com Wed Dec 6 01:14:55 2023 From: lkp at intel.com (kernel test robot) Date: Tue, 5 Dec 2023 22:14:55 +0800 Subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X In-Reply-To: <20231204055650.788388-3-kcfeng0@nuvoton.com> References: <20231204055650.788388-3-kcfeng0@nuvoton.com> Message-ID: <202312052243.AbRqbNyT-lkp@intel.com> Hi, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.7-rc4 next-20231205] [cannot apply to groeck-staging/hwmon-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/baneric926-gmail-com/dt-bindings-hwmon-Add-nct736x-bindings/20231204-135942 base: linus/master patch link: https://lore.kernel.org/r/20231204055650.788388-3-kcfeng0%40nuvoton.com patch subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X config: um-randconfig-001-20231205 (https://download.01.org/0day-ci/archive/20231205/202312052243.AbRqbNyT-lkp at intel.com/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231205/202312052243.AbRqbNyT-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312052243.AbRqbNyT-lkp at intel.com/ All warnings (new ones prefixed by >>): drivers/hwmon/nct736x.c: In function 'nct736x_init_chip.constprop': >> drivers/hwmon/nct736x.c:367:15: warning: 'gpio0_3' is used uninitialized [-Wuninitialized] 367 | ret = nct736x_write_reg(client, NCT736X_REG_GPIO_0_3, gpio0_3); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/gpio0_3 +367 drivers/hwmon/nct736x.c 334 335 static int nct736x_init_chip(struct i2c_client *client, 336 u32 pwm_mask, u32 fanin_mask, u32 wdt_cfg) 337 { 338 const struct i2c_device_id *id = i2c_match_id(nct736x_id, client); 339 u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; 340 int ret; 341 342 for (i = 0; i < NCT736X_PWM_COUNT; i++) { 343 if (i < 4) { 344 if (pwm_mask & BIT_CHECK(i)) 345 gpio0_3 |= PWM_SEL(i); 346 if (fanin_mask & BIT_CHECK(i)) 347 gpio10_13 |= FANIN_SEL(i); 348 } else if (i < 8) { 349 if (pwm_mask & BIT_CHECK(i)) 350 gpio4_7 |= PWM_SEL(i); 351 if (fanin_mask & BIT_CHECK(i)) 352 gpio14_17 |= FANIN_SEL(i); 353 } else if (i < 12) { 354 if (pwm_mask & BIT_CHECK(i)) 355 gpio10_13 |= PWM_SEL(i); 356 if (fanin_mask & BIT_CHECK(i)) 357 gpio0_3 |= FANIN_SEL(i); 358 } else { 359 if (pwm_mask & BIT_CHECK(i)) 360 gpio14_17 |= PWM_SEL(i); 361 if (fanin_mask & BIT_CHECK(i)) 362 gpio4_7 |= FANIN_SEL(i); 363 } 364 } 365 366 /* Pin Function Configuration */ > 367 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_0_3, gpio0_3); 368 if (ret < 0) 369 return ret; 370 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_4_7, gpio4_7); 371 if (ret < 0) 372 return ret; 373 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_10_13, gpio10_13); 374 if (ret < 0) 375 return ret; 376 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_14_17, gpio14_17); 377 if (ret < 0) 378 return ret; 379 380 /* PWM and FANIN Monitoring Enable */ 381 ret = nct736x_write_reg(client, NCT736X_REG_PWMEN_0_7, 382 pwm_mask & 0xff); 383 if (ret < 0) 384 return ret; 385 ret = nct736x_write_reg(client, 386 NCT736X_REG_PWMEN_8_15, (pwm_mask >> 8) & 0xff); 387 if (ret < 0) 388 return ret; 389 ret = nct736x_write_reg(client, NCT736X_REG_FANINEN_0_7, 390 fanin_mask & 0xff); 391 if (ret < 0) 392 return ret; 393 ret = nct736x_write_reg(client, NCT736X_REG_FANINEN_8_15, 394 (fanin_mask >> 8) & 0xff); 395 if (ret < 0) 396 return ret; 397 398 /* Watchdog Timer Configuration */ 399 if (wdt_cfg != 0xff && id->driver_data == nct7363) { 400 ret = nct736x_write_reg(client, NCT7363_REG_WDT, wdt_cfg); 401 if (ret < 0) 402 return ret; 403 } 404 405 return 0; 406 } 407 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From linux at armlinux.org.uk Wed Dec 6 01:50:58 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 14:50:58 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 02:52:24PM +0100, Andrew Lunn wrote: > On Tue, Dec 05, 2023 at 02:31:41PM +0300, Serge Semin wrote: > > On Tue, Dec 05, 2023 at 10:49:47AM +0000, Russell King (Oracle) wrote: > > > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > > > or explicitly registered in the MDIO subsystem by means of the > > > > mdiobus_register_board_info() method there is no point in creating the > > > > dummy MDIO device instance in order to get the DW XPCS handler since the > > > > MDIO core subsystem will create the device during the MDIO bus > > > > registration procedure. > > > > > > > > Please reword this overly long sentence. > > > > Ok. > > > > > > > > If they're left unmasked, what prevents them being created as PHY > > > devices? > > > > Not sure I fully get what you meant. If they are left unmasked the > > MDIO-device descriptor will be created by the MDIO subsystem anyway. > > What the point in creating another one? > > Saying what Russell said, in a different way: > > /* > * Return true if the child node is for a phy. It must either: > * o Compatible string of "ethernet-phy-idX.X" > * o Compatible string of "ethernet-phy-ieee802.3-c45" > * o Compatible string of "ethernet-phy-ieee802.3-c22" > * o In the white list above (and issue a warning) > * o No compatibility string > * > * A device which is not a phy is expected to have a compatible string > * indicating what sort of device it is. > */ > bool of_mdiobus_child_is_phy(struct device_node *child) > > So when walking the bus, if a node is found which fits these criteria, > its assumed to be a PHY. > > Anything on the MDIO bus which is not a PHY needs to use a compatible. Right. I'd actually forgotten about the firmware-based walking, and was thinking more of the non-firmware bus scanning as the commit message was talking about being _unmasked_ and the only mask we have is bus->phy_mask. It seems to me that this is yet another case of a really confusing commit message making review harder than it needs to be. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From linux at armlinux.org.uk Wed Dec 6 01:54:00 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 5 Dec 2023 14:54:00 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 01:46:44PM +0000, Russell King (Oracle) wrote: > For your use case, it would be: > > mdiodev = bus->mdio_map[addr]; By the way, this should be: mdiodev = mdiobus_find_device(bus, addr); if (!mdiodev) return ERR_PTR(-ENODEV); to avoid a layering violation. At some point, we should implement mdiobus_get_mdiodev() which also deals with the refcount. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From lkp at intel.com Wed Dec 6 10:03:46 2023 From: lkp at intel.com (kernel test robot) Date: Wed, 6 Dec 2023 07:03:46 +0800 Subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" In-Reply-To: <20231205103559.9605-12-fancer.lancer@gmail.com> References: <20231205103559.9605-12-fancer.lancer@gmail.com> Message-ID: <202312060634.Cblfigt2-lkp@intel.com> Hi Serge, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Serge-Semin/net-pcs-xpcs-Drop-sentinel-entry-from-2500basex-ifaces-list/20231205-183808 base: net-next/main patch link: https://lore.kernel.org/r/20231205103559.9605-12-fancer.lancer%40gmail.com patch subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" config: arc-randconfig-001-20231206 (https://download.01.org/0day-ci/archive/20231206/202312060634.Cblfigt2-lkp at intel.com/config) compiler: arc-elf-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060634.Cblfigt2-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312060634.Cblfigt2-lkp at intel.com/ All error/warnings (new ones prefixed by >>): drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c: In function 'txgbe_mdio_pcs_init': >> drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:150:16: error: implicit declaration of function 'xpcs_create_mdiodev'; did you mean 'xpcs_create_byaddr'? [-Werror=implicit-function-declaration] 150 | xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); | ^~~~~~~~~~~~~~~~~~~ | xpcs_create_byaddr >> drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:150:14: warning: assignment to 'struct dw_xpcs *' from 'int' makes pointer from integer without a cast [-Wint-conversion] 150 | xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); | ^ cc1: some warnings being treated as errors vim +150 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c 854cace61387b6 Jiawen Wu 2023-06-06 121 854cace61387b6 Jiawen Wu 2023-06-06 122 static int txgbe_mdio_pcs_init(struct txgbe *txgbe) 854cace61387b6 Jiawen Wu 2023-06-06 123 { 854cace61387b6 Jiawen Wu 2023-06-06 124 struct mii_bus *mii_bus; 854cace61387b6 Jiawen Wu 2023-06-06 125 struct dw_xpcs *xpcs; 854cace61387b6 Jiawen Wu 2023-06-06 126 struct pci_dev *pdev; 854cace61387b6 Jiawen Wu 2023-06-06 127 struct wx *wx; 854cace61387b6 Jiawen Wu 2023-06-06 128 int ret = 0; 854cace61387b6 Jiawen Wu 2023-06-06 129 854cace61387b6 Jiawen Wu 2023-06-06 130 wx = txgbe->wx; 854cace61387b6 Jiawen Wu 2023-06-06 131 pdev = wx->pdev; 854cace61387b6 Jiawen Wu 2023-06-06 132 854cace61387b6 Jiawen Wu 2023-06-06 133 mii_bus = devm_mdiobus_alloc(&pdev->dev); 854cace61387b6 Jiawen Wu 2023-06-06 134 if (!mii_bus) 854cace61387b6 Jiawen Wu 2023-06-06 135 return -ENOMEM; 854cace61387b6 Jiawen Wu 2023-06-06 136 854cace61387b6 Jiawen Wu 2023-06-06 137 mii_bus->name = "txgbe_pcs_mdio_bus"; 854cace61387b6 Jiawen Wu 2023-06-06 138 mii_bus->read_c45 = &txgbe_pcs_read; 854cace61387b6 Jiawen Wu 2023-06-06 139 mii_bus->write_c45 = &txgbe_pcs_write; 854cace61387b6 Jiawen Wu 2023-06-06 140 mii_bus->parent = &pdev->dev; 854cace61387b6 Jiawen Wu 2023-06-06 141 mii_bus->phy_mask = ~0; 854cace61387b6 Jiawen Wu 2023-06-06 142 mii_bus->priv = wx; 854cace61387b6 Jiawen Wu 2023-06-06 143 snprintf(mii_bus->id, MII_BUS_ID_SIZE, "txgbe_pcs-%x", d8c21ef7b2b147 Xiongfeng Wang 2023-08-08 144 pci_dev_id(pdev)); 854cace61387b6 Jiawen Wu 2023-06-06 145 854cace61387b6 Jiawen Wu 2023-06-06 146 ret = devm_mdiobus_register(&pdev->dev, mii_bus); 854cace61387b6 Jiawen Wu 2023-06-06 147 if (ret) 854cace61387b6 Jiawen Wu 2023-06-06 148 return ret; 854cace61387b6 Jiawen Wu 2023-06-06 149 854cace61387b6 Jiawen Wu 2023-06-06 @150 xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); 854cace61387b6 Jiawen Wu 2023-06-06 151 if (IS_ERR(xpcs)) 854cace61387b6 Jiawen Wu 2023-06-06 152 return PTR_ERR(xpcs); 854cace61387b6 Jiawen Wu 2023-06-06 153 854cace61387b6 Jiawen Wu 2023-06-06 154 txgbe->xpcs = xpcs; 854cace61387b6 Jiawen Wu 2023-06-06 155 854cace61387b6 Jiawen Wu 2023-06-06 156 return 0; 854cace61387b6 Jiawen Wu 2023-06-06 157 } 854cace61387b6 Jiawen Wu 2023-06-06 158 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From patrick at stwcx.xyz Wed Dec 6 10:48:42 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Tue, 5 Dec 2023 17:48:42 -0600 Subject: [PATCH dev-5.6 2/3] net/ncsi: Fix netlink major/minor version numbers In-Reply-To: <20231205234843.4013767-1-patrick@stwcx.xyz> References: <20231205234843.4013767-1-patrick@stwcx.xyz> Message-ID: <20231205234843.4013767-2-patrick@stwcx.xyz> From: Peter Delevoryas The netlink interface for major and minor version numbers doesn't actually return the major and minor version numbers. It reports a u32 that contains the (major, minor, update, alpha1) components as the major version number, and then alpha2 as the minor version number. For whatever reason, the u32 byte order was reversed (ntohl): maybe it was assumed that the encoded value was a single big-endian u32, and alpha2 was the minor version. The correct way to get the supported NC-SI version from the network controller is to parse the Get Version ID response as described in 8.4.44 of the NC-SI spec[1]. Get Version ID Response Packet Format Bits +--------+--------+--------+--------+ Bytes | 31..24 | 23..16 | 15..8 | 7..0 | +-------+--------+--------+--------+--------+ | 0..15 | NC-SI Header | +-------+--------+--------+--------+--------+ | 16..19| Response code | Reason code | +-------+--------+--------+--------+--------+ |20..23 | Major | Minor | Update | Alpha1 | +-------+--------+--------+--------+--------+ |24..27 | reserved | Alpha2 | +-------+--------+--------+--------+--------+ | .... other stuff .... | The major, minor, and update fields are all binary-coded decimal (BCD) encoded [2]. The spec provides examples below the Get Version ID response format in section 8.4.44.1, but for practical purposes, this is an example from a live network card: root at bmc:~# ncsi-util 0x15 NC-SI Command Response: cmd: GET_VERSION_ID(0x15) Response: COMMAND_COMPLETED(0x0000) Reason: NO_ERROR(0x0000) Payload length = 40 20: 0xf1 0xf1 0xf0 0x00 <<<<<<<<< (major, minor, update, alpha1) 24: 0x00 0x00 0x00 0x00 <<<<<<<<< (_, _, _, alpha2) 28: 0x6d 0x6c 0x78 0x30 32: 0x2e 0x31 0x00 0x00 36: 0x00 0x00 0x00 0x00 40: 0x16 0x1d 0x07 0xd2 44: 0x10 0x1d 0x15 0xb3 48: 0x00 0x17 0x15 0xb3 52: 0x00 0x00 0x81 0x19 This should be parsed as "1.1.0". "f" in the upper-nibble means to ignore it, contributing zero. If both nibbles are "f", I think the whole field is supposed to be ignored. Major and minor are "required", meaning they're not supposed to be "ff", but the update field is "optional" so I think it can be ff. I think the simplest thing to do is just set the major and minor to zero instead of juggling some conditional logic or something. bcd2bin() from "include/linux/bcd.h" seems to assume both nibbles are 0-9, so I've provided a custom BCD decoding function. Alpha1 and alpha2 are ISO/IEC 8859-1 encoded, which just means ASCII characters as far as I can tell, although the full encoding table for non-alphabetic characters is slightly different (I think). I imagine the alpha fields are just supposed to be alphabetic characters, but I haven't seen any network cards actually report a non-zero value for either. If people wrote software against this netlink behavior, and were parsing the major and minor versions themselves from the u32, then this would definitely break their code. [1] https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.0.0.pdf [2] https://en.wikipedia.org/wiki/Binary-coded_decimal [2] https://en.wikipedia.org/wiki/ISO/IEC_8859-1 Signed-off-by: Peter Delevoryas Fixes: 138635cc27c9 ("net/ncsi: NCSI response packet handler") Signed-off-by: David S. Miller (cherry picked from commit 3084b58bfd0b9e4b5e034f31f31b42977db35f12) --- net/ncsi/internal.h | 7 +++++-- net/ncsi/ncsi-netlink.c | 4 ++-- net/ncsi/ncsi-pkt.h | 7 +++++-- net/ncsi/ncsi-rsp.c | 26 ++++++++++++++++++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/net/ncsi/internal.h b/net/ncsi/internal.h index 03757e76bb6b..374412ed780b 100644 --- a/net/ncsi/internal.h +++ b/net/ncsi/internal.h @@ -105,8 +105,11 @@ enum { struct ncsi_channel_version { - u32 version; /* Supported BCD encoded NCSI version */ - u32 alpha2; /* Supported BCD encoded NCSI version */ + u8 major; /* NCSI version major */ + u8 minor; /* NCSI version minor */ + u8 update; /* NCSI version update */ + char alpha1; /* NCSI version alpha1 */ + char alpha2; /* NCSI version alpha2 */ u8 fw_name[12]; /* Firmware name string */ u32 fw_version; /* Firmware version */ u16 pci_ids[4]; /* PCI identification */ diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c index d27f4eccce6d..fe681680b5d9 100644 --- a/net/ncsi/ncsi-netlink.c +++ b/net/ncsi/ncsi-netlink.c @@ -71,8 +71,8 @@ static int ncsi_write_channel_info(struct sk_buff *skb, if (nc == nc->package->preferred_channel) nla_put_flag(skb, NCSI_CHANNEL_ATTR_FORCED); - nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.version); - nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.alpha2); + nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MAJOR, nc->version.major); + nla_put_u32(skb, NCSI_CHANNEL_ATTR_VERSION_MINOR, nc->version.minor); nla_put_string(skb, NCSI_CHANNEL_ATTR_VERSION_STR, nc->version.fw_name); vid_nest = nla_nest_start_noflag(skb, NCSI_CHANNEL_ATTR_VLAN_LIST); diff --git a/net/ncsi/ncsi-pkt.h b/net/ncsi/ncsi-pkt.h index ba66c7dc3a21..c9d1da34dc4d 100644 --- a/net/ncsi/ncsi-pkt.h +++ b/net/ncsi/ncsi-pkt.h @@ -197,9 +197,12 @@ struct ncsi_rsp_gls_pkt { /* Get Version ID */ struct ncsi_rsp_gvi_pkt { struct ncsi_rsp_pkt_hdr rsp; /* Response header */ - __be32 ncsi_version; /* NCSI version */ + unsigned char major; /* NCSI version major */ + unsigned char minor; /* NCSI version minor */ + unsigned char update; /* NCSI version update */ + unsigned char alpha1; /* NCSI version alpha1 */ unsigned char reserved[3]; /* Reserved */ - unsigned char alpha2; /* NCSI version */ + unsigned char alpha2; /* NCSI version alpha2 */ unsigned char fw_name[12]; /* f/w name string */ __be32 fw_version; /* f/w version */ __be16 pci_ids[4]; /* PCI IDs */ diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index 069c2659074b..480e80e3c283 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -19,6 +19,19 @@ #include "ncsi-pkt.h" #include "ncsi-netlink.h" +/* Nibbles within [0xA, 0xF] add zero "0" to the returned value. + * Optional fields (encoded as 0xFF) will default to zero. + */ +static u8 decode_bcd_u8(u8 x) +{ + int lo = x & 0xF; + int hi = x >> 4; + + lo = lo < 0xA ? lo : 0; + hi = hi < 0xA ? hi : 0; + return lo + hi * 10; +} + static int ncsi_validate_rsp_pkt(struct ncsi_request *nr, unsigned short payload) { @@ -755,9 +768,18 @@ static int ncsi_rsp_handler_gvi(struct ncsi_request *nr) if (!nc) return -ENODEV; - /* Update to channel's version info */ + /* Update channel's version info + * + * Major, minor, and update fields are supposed to be + * unsigned integers encoded as packed BCD. + * + * Alpha1 and alpha2 are ISO/IEC 8859-1 characters. + */ ncv = &nc->version; - ncv->version = ntohl(rsp->ncsi_version); + ncv->major = decode_bcd_u8(rsp->major); + ncv->minor = decode_bcd_u8(rsp->minor); + ncv->update = decode_bcd_u8(rsp->update); + ncv->alpha1 = rsp->alpha1; ncv->alpha2 = rsp->alpha2; memcpy(ncv->fw_name, rsp->fw_name, 12); ncv->fw_version = ntohl(rsp->fw_version); -- 2.41.0 From patrick at stwcx.xyz Wed Dec 6 10:48:41 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Tue, 5 Dec 2023 17:48:41 -0600 Subject: [PATCH dev-5.6 1/3] net/ncsi: Simplify Kconfig/dts control flow Message-ID: <20231205234843.4013767-1-patrick@stwcx.xyz> From: Peter Delevoryas Background: 1. CONFIG_NCSI_OEM_CMD_KEEP_PHY If this is enabled, we send an extra OEM Intel command in the probe sequence immediately after discovering a channel (e.g. after "Clear Initial State"). 2. CONFIG_NCSI_OEM_CMD_GET_MAC If this is enabled, we send one of 3 OEM "Get MAC Address" commands from Broadcom, Mellanox (Nvidida), and Intel in the *configuration* sequence for a channel. 3. mellanox,multi-host (or mlx,multi-host) Introduced by this patch: https://lore.kernel.org/all/20200108234341.2590674-1-vijaykhemka at fb.com/ Which was actually originally from cosmo.chou at quantatw.com: https://github.com/facebook/openbmc-linux/commit/9f132a10ec48db84613519258cd8a317fb9c8f1b Cosmo claimed that the Nvidia ConnectX-4 and ConnectX-6 NIC's don't respond to Get Version ID, et. al in the probe sequence unless you send the Set MC Affinity command first. Problem Statement: We've been using a combination of #ifdef code blocks and IS_ENABLED() conditions to conditionally send these OEM commands. It makes adding any new code around these commands hard to understand. Solution: In this patch, I just want to remove the conditionally compiled blocks of code, and always use IS_ENABLED(...) to do dynamic control flow. I don't think the small amount of code this adds to non-users of the OEM Kconfigs is a big deal. Signed-off-by: Peter Delevoryas Signed-off-by: David S. Miller (cherry picked from commit c797ce168930ce3d62a9b7fc4d7040963ee6a01e) --- net/ncsi/ncsi-manage.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index d9da942ad53d..f3d7fe86fea1 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -689,8 +689,6 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc, return 0; } -#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY) - static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca) { unsigned char data[NCSI_OEM_INTEL_CMD_KEEP_PHY_LEN]; @@ -716,10 +714,6 @@ static int ncsi_oem_keep_phy_intel(struct ncsi_cmd_arg *nca) return ret; } -#endif - -#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) - /* NCSI OEM Command APIs */ static int ncsi_oem_gma_handler_bcm(struct ncsi_cmd_arg *nca) { @@ -856,8 +850,6 @@ static int ncsi_gma_handler(struct ncsi_cmd_arg *nca, unsigned int mf_id) return nch->handler(nca); } -#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ - /* Determine if a given channel from the channel_queue should be used for Tx */ static bool ncsi_channel_is_tx(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc) @@ -1039,20 +1031,18 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) goto error; } - nd->state = ncsi_dev_state_config_oem_gma; + nd->state = IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) + ? ncsi_dev_state_config_oem_gma + : ncsi_dev_state_config_clear_vids; break; case ncsi_dev_state_config_oem_gma: nd->state = ncsi_dev_state_config_clear_vids; - ret = -1; -#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) nca.type = NCSI_PKT_CMD_OEM; nca.package = np->id; nca.channel = nc->id; ndp->pending_req_num = 1; ret = ncsi_gma_handler(&nca, nc->version.mf_id); -#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ - if (ret < 0) schedule_work(&ndp->work); @@ -1404,7 +1394,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) schedule_work(&ndp->work); break; -#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_GET_MAC) case ncsi_dev_state_probe_mlx_gma: ndp->pending_req_num = 1; @@ -1429,7 +1418,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) nd->state = ncsi_dev_state_probe_cis; break; -#endif /* CONFIG_NCSI_OEM_CMD_GET_MAC */ case ncsi_dev_state_probe_cis: ndp->pending_req_num = NCSI_RESERVED_CHANNEL; @@ -1447,7 +1435,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) if (IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY)) nd->state = ncsi_dev_state_probe_keep_phy; break; -#if IS_ENABLED(CONFIG_NCSI_OEM_CMD_KEEP_PHY) case ncsi_dev_state_probe_keep_phy: ndp->pending_req_num = 1; @@ -1460,7 +1447,6 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp) nd->state = ncsi_dev_state_probe_gvi; break; -#endif /* CONFIG_NCSI_OEM_CMD_KEEP_PHY */ case ncsi_dev_state_probe_gvi: case ncsi_dev_state_probe_gc: case ncsi_dev_state_probe_gls: -- 2.41.0 From patrick at stwcx.xyz Wed Dec 6 10:48:43 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Tue, 5 Dec 2023 17:48:43 -0600 Subject: [PATCH dev-5.6 3/3] net/ncsi: Add NC-SI 1.2 Get MC MAC Address command In-Reply-To: <20231205234843.4013767-1-patrick@stwcx.xyz> References: <20231205234843.4013767-1-patrick@stwcx.xyz> Message-ID: <20231205234843.4013767-3-patrick@stwcx.xyz> From: Peter Delevoryas This change adds support for the NC-SI 1.2 Get MC MAC Address command, specified here: https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.2.0.pdf It serves the exact same function as the existing OEM Get MAC Address commands, so if a channel reports that it supports NC-SI 1.2, we prefer to use the standard command rather than the OEM command. Verified with an invalid MAC address and 2 valid ones: [ 55.137072] ftgmac100 1e690000.ftgmac eth0: NCSI: Received 3 provisioned MAC addresses [ 55.137614] ftgmac100 1e690000.ftgmac eth0: NCSI: MAC address 0: 00:00:00:00:00:00 [ 55.138026] ftgmac100 1e690000.ftgmac eth0: NCSI: MAC address 1: fa:ce:b0:0c:20:22 [ 55.138528] ftgmac100 1e690000.ftgmac eth0: NCSI: MAC address 2: fa:ce:b0:0c:20:23 [ 55.139241] ftgmac100 1e690000.ftgmac eth0: NCSI: Unable to assign 00:00:00:00:00:00 to device [ 55.140098] ftgmac100 1e690000.ftgmac eth0: NCSI: Set MAC address to fa:ce:b0:0c:20:22 Signed-off-by: Peter Delevoryas Signed-off-by: Patrick Williams Signed-off-by: David S. Miller (cherry picked from commit b8291cf3d1180b5b61299922f17c9441616a805a) --- net/ncsi/ncsi-cmd.c | 3 ++- net/ncsi/ncsi-manage.c | 9 +++++++-- net/ncsi/ncsi-pkt.h | 10 ++++++++++ net/ncsi/ncsi-rsp.c | 41 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/net/ncsi/ncsi-cmd.c b/net/ncsi/ncsi-cmd.c index fd2236ee9a79..b3ff37a181d7 100644 --- a/net/ncsi/ncsi-cmd.c +++ b/net/ncsi/ncsi-cmd.c @@ -270,7 +270,8 @@ static struct ncsi_cmd_handler { { NCSI_PKT_CMD_GPS, 0, ncsi_cmd_handler_default }, { NCSI_PKT_CMD_OEM, -1, ncsi_cmd_handler_oem }, { NCSI_PKT_CMD_PLDM, 0, NULL }, - { NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default } + { NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default }, + { NCSI_PKT_CMD_GMCMA, 0, ncsi_cmd_handler_default } }; static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca) diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c index f3d7fe86fea1..745c788f1d1d 100644 --- a/net/ncsi/ncsi-manage.c +++ b/net/ncsi/ncsi-manage.c @@ -1038,11 +1038,16 @@ static void ncsi_configure_channel(struct ncsi_dev_priv *ndp) case ncsi_dev_state_config_oem_gma: nd->state = ncsi_dev_state_config_clear_vids; - nca.type = NCSI_PKT_CMD_OEM; nca.package = np->id; nca.channel = nc->id; ndp->pending_req_num = 1; - ret = ncsi_gma_handler(&nca, nc->version.mf_id); + if (nc->version.major >= 1 && nc->version.minor >= 2) { + nca.type = NCSI_PKT_CMD_GMCMA; + ret = ncsi_xmit_cmd(&nca); + } else { + nca.type = NCSI_PKT_CMD_OEM; + ret = ncsi_gma_handler(&nca, nc->version.mf_id); + } if (ret < 0) schedule_work(&ndp->work); diff --git a/net/ncsi/ncsi-pkt.h b/net/ncsi/ncsi-pkt.h index c9d1da34dc4d..f2f3b5c1b941 100644 --- a/net/ncsi/ncsi-pkt.h +++ b/net/ncsi/ncsi-pkt.h @@ -338,6 +338,14 @@ struct ncsi_rsp_gpuuid_pkt { __be32 checksum; }; +/* Get MC MAC Address */ +struct ncsi_rsp_gmcma_pkt { + struct ncsi_rsp_pkt_hdr rsp; + unsigned char address_count; + unsigned char reserved[3]; + unsigned char addresses[][ETH_ALEN]; +}; + /* AEN: Link State Change */ struct ncsi_aen_lsc_pkt { struct ncsi_aen_pkt_hdr aen; /* AEN header */ @@ -398,6 +406,7 @@ struct ncsi_aen_hncdsc_pkt { #define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */ #define NCSI_PKT_CMD_QPNPR 0x56 /* Query Pending NC PLDM request */ #define NCSI_PKT_CMD_SNPR 0x57 /* Send NC PLDM Reply */ +#define NCSI_PKT_CMD_GMCMA 0x58 /* Get MC MAC Address */ /* NCSI packet responses */ @@ -433,6 +442,7 @@ struct ncsi_aen_hncdsc_pkt { #define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80) #define NCSI_PKT_RSP_QPNPR (NCSI_PKT_CMD_QPNPR + 0x80) #define NCSI_PKT_RSP_SNPR (NCSI_PKT_CMD_SNPR + 0x80) +#define NCSI_PKT_RSP_GMCMA (NCSI_PKT_CMD_GMCMA + 0x80) /* NCSI response code/reason */ #define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command Completed */ diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index 480e80e3c283..bee290d0f48b 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -1091,6 +1091,44 @@ static int ncsi_rsp_handler_netlink(struct ncsi_request *nr) return ret; } +static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr) +{ + struct ncsi_dev_priv *ndp = nr->ndp; + struct net_device *ndev = ndp->ndev.dev; + struct ncsi_rsp_gmcma_pkt *rsp; + struct sockaddr saddr; + int ret = -1; + int i; + + rsp = (struct ncsi_rsp_gmcma_pkt *)skb_network_header(nr->rsp); + saddr.sa_family = ndev->type; + ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; + + netdev_info(ndev, "NCSI: Received %d provisioned MAC addresses\n", + rsp->address_count); + for (i = 0; i < rsp->address_count; i++) { + netdev_info(ndev, "NCSI: MAC address %d: %02x:%02x:%02x:%02x:%02x:%02x\n", + i, rsp->addresses[i][0], rsp->addresses[i][1], + rsp->addresses[i][2], rsp->addresses[i][3], + rsp->addresses[i][4], rsp->addresses[i][5]); + } + + for (i = 0; i < rsp->address_count; i++) { + memcpy(saddr.sa_data, &rsp->addresses[i], ETH_ALEN); + ret = ndev->netdev_ops->ndo_set_mac_address(ndev, &saddr); + if (ret < 0) { + netdev_warn(ndev, "NCSI: Unable to assign %pM to device\n", + saddr.sa_data); + continue; + } + netdev_warn(ndev, "NCSI: Set MAC address to %pM\n", saddr.sa_data); + break; + } + + ndp->gma_flag = ret == 0; + return ret; +} + static struct ncsi_rsp_handler { unsigned char type; int payload; @@ -1127,7 +1165,8 @@ static struct ncsi_rsp_handler { { NCSI_PKT_RSP_PLDM, -1, ncsi_rsp_handler_pldm }, { NCSI_PKT_RSP_GPUUID, 20, ncsi_rsp_handler_gpuuid }, { NCSI_PKT_RSP_QPNPR, -1, ncsi_rsp_handler_pldm }, - { NCSI_PKT_RSP_SNPR, -1, ncsi_rsp_handler_pldm } + { NCSI_PKT_RSP_SNPR, -1, ncsi_rsp_handler_pldm }, + { NCSI_PKT_RSP_GMCMA, -1, ncsi_rsp_handler_gmcma }, }; int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev, -- 2.41.0 From lkp at intel.com Wed Dec 6 11:19:07 2023 From: lkp at intel.com (kernel test robot) Date: Wed, 6 Dec 2023 08:19:07 +0800 Subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device In-Reply-To: <20231205103559.9605-14-fancer.lancer@gmail.com> References: <20231205103559.9605-14-fancer.lancer@gmail.com> Message-ID: <202312060845.lDDRDWET-lkp@intel.com> Hi Serge, kernel test robot noticed the following build errors: [auto build test ERROR on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Serge-Semin/net-pcs-xpcs-Drop-sentinel-entry-from-2500basex-ifaces-list/20231205-183808 base: net-next/main patch link: https://lore.kernel.org/r/20231205103559.9605-14-fancer.lancer%40gmail.com patch subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device config: x86_64-kexec (https://download.01.org/0day-ci/archive/20231206/202312060845.lDDRDWET-lkp at intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060845.lDDRDWET-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312060845.lDDRDWET-lkp at intel.com/ All errors (new ones prefixed by >>): drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c: In function 'intel_mgbe_common_data': >> drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:646:31: error: 'clk' undeclared (first use in this function) 646 | clk_disable_unprepare(clk); | ^~~ drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:646:31: note: each undeclared identifier is reported only once for each function it appears in vim +/clk +646 drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c 446 447 static int intel_mgbe_common_data(struct pci_dev *pdev, 448 struct plat_stmmacenet_data *plat) 449 { 450 struct fwnode_handle *fwnode; 451 char clk_name[20]; 452 int ret; 453 int i; 454 455 plat->pdev = pdev; 456 plat->phy_addr = -1; 457 plat->clk_csr = 5; 458 plat->has_gmac = 0; 459 plat->has_gmac4 = 1; 460 plat->force_sf_dma_mode = 0; 461 plat->flags |= (STMMAC_FLAG_TSO_EN | STMMAC_FLAG_SPH_DISABLE); 462 463 /* Multiplying factor to the clk_eee_i clock time 464 * period to make it closer to 100 ns. This value 465 * should be programmed such that the clk_eee_time_period * 466 * (MULT_FACT_100NS + 1) should be within 80 ns to 120 ns 467 * clk_eee frequency is 19.2Mhz 468 * clk_eee_time_period is 52ns 469 * 52ns * (1 + 1) = 104ns 470 * MULT_FACT_100NS = 1 471 */ 472 plat->mult_fact_100ns = 1; 473 474 plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP; 475 476 for (i = 0; i < plat->rx_queues_to_use; i++) { 477 plat->rx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB; 478 plat->rx_queues_cfg[i].chan = i; 479 480 /* Disable Priority config by default */ 481 plat->rx_queues_cfg[i].use_prio = false; 482 483 /* Disable RX queues routing by default */ 484 plat->rx_queues_cfg[i].pkt_route = 0x0; 485 } 486 487 for (i = 0; i < plat->tx_queues_to_use; i++) { 488 plat->tx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB; 489 490 /* Disable Priority config by default */ 491 plat->tx_queues_cfg[i].use_prio = false; 492 /* Default TX Q0 to use TSO and rest TXQ for TBS */ 493 if (i > 0) 494 plat->tx_queues_cfg[i].tbs_en = 1; 495 } 496 497 /* FIFO size is 4096 bytes for 1 tx/rx queue */ 498 plat->tx_fifo_size = plat->tx_queues_to_use * 4096; 499 plat->rx_fifo_size = plat->rx_queues_to_use * 4096; 500 501 plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WRR; 502 plat->tx_queues_cfg[0].weight = 0x09; 503 plat->tx_queues_cfg[1].weight = 0x0A; 504 plat->tx_queues_cfg[2].weight = 0x0B; 505 plat->tx_queues_cfg[3].weight = 0x0C; 506 plat->tx_queues_cfg[4].weight = 0x0D; 507 plat->tx_queues_cfg[5].weight = 0x0E; 508 plat->tx_queues_cfg[6].weight = 0x0F; 509 plat->tx_queues_cfg[7].weight = 0x10; 510 511 plat->dma_cfg->pbl = 32; 512 plat->dma_cfg->pblx8 = true; 513 plat->dma_cfg->fixed_burst = 0; 514 plat->dma_cfg->mixed_burst = 0; 515 plat->dma_cfg->aal = 0; 516 plat->dma_cfg->dche = true; 517 518 plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi), 519 GFP_KERNEL); 520 if (!plat->axi) 521 return -ENOMEM; 522 523 plat->axi->axi_lpi_en = 0; 524 plat->axi->axi_xit_frm = 0; 525 plat->axi->axi_wr_osr_lmt = 1; 526 plat->axi->axi_rd_osr_lmt = 1; 527 plat->axi->axi_blen[0] = 4; 528 plat->axi->axi_blen[1] = 8; 529 plat->axi->axi_blen[2] = 16; 530 531 plat->ptp_max_adj = plat->clk_ptp_rate; 532 plat->eee_usecs_rate = plat->clk_ptp_rate; 533 534 /* Set system clock */ 535 sprintf(clk_name, "%s-%s", "stmmac", pci_name(pdev)); 536 537 plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev, 538 clk_name, NULL, 0, 539 plat->clk_ptp_rate); 540 541 if (IS_ERR(plat->stmmac_clk)) { 542 dev_warn(&pdev->dev, "Fail to register stmmac-clk\n"); 543 plat->stmmac_clk = NULL; 544 } 545 546 ret = clk_prepare_enable(plat->stmmac_clk); 547 if (ret) { 548 clk_unregister_fixed_rate(plat->stmmac_clk); 549 return ret; 550 } 551 552 plat->ptp_clk_freq_config = intel_mgbe_ptp_clk_freq_config; 553 554 /* Set default value for multicast hash bins */ 555 plat->multicast_filter_bins = HASH_TABLE_SIZE; 556 557 /* Set default value for unicast filter entries */ 558 plat->unicast_filter_entries = 1; 559 560 /* Set the maxmtu to a default of JUMBO_LEN */ 561 plat->maxmtu = JUMBO_LEN; 562 563 plat->flags |= STMMAC_FLAG_VLAN_FAIL_Q_EN; 564 565 /* Use the last Rx queue */ 566 plat->vlan_fail_q = plat->rx_queues_to_use - 1; 567 568 /* For fixed-link setup, we allow phy-mode setting */ 569 fwnode = dev_fwnode(&pdev->dev); 570 if (fwnode) { 571 int phy_mode; 572 573 /* "phy-mode" setting is optional. If it is set, 574 * we allow either sgmii or 1000base-x for now. 575 */ 576 phy_mode = fwnode_get_phy_mode(fwnode); 577 if (phy_mode >= 0) { 578 if (phy_mode == PHY_INTERFACE_MODE_SGMII || 579 phy_mode == PHY_INTERFACE_MODE_1000BASEX) 580 plat->phy_interface = phy_mode; 581 else 582 dev_warn(&pdev->dev, "Invalid phy-mode\n"); 583 } 584 } 585 586 /* Intel mgbe SGMII interface uses pcs-xcps */ 587 if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || 588 plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { 589 struct mdio_board_info *xpcs_info; 590 591 xpcs_info = devm_kzalloc(&pdev->dev, 592 sizeof(*xpcs_info) + MII_BUS_ID_SIZE, 593 GFP_KERNEL); 594 if (!xpcs_info) { 595 ret = -ENOMEM; 596 goto err_alloc_info; 597 } 598 599 xpcs_info->bus_id = (void *)xpcs_info + sizeof(*xpcs_info); 600 snprintf((char *)xpcs_info->bus_id, MII_BUS_ID_SIZE, 601 "stmmac-%x", plat->bus_id); 602 603 snprintf(xpcs_info->modalias, MDIO_NAME_SIZE, "dwxpcs"); 604 605 xpcs_info->mdio_addr = INTEL_MGBE_XPCS_ADDR; 606 607 ret = mdiobus_register_board_info(xpcs_info, 1); 608 if (ret) 609 goto err_alloc_info; 610 611 plat->mdio_bus_data->has_xpcs = true; 612 plat->mdio_bus_data->xpcs_an_inband = true; 613 } 614 615 /* For fixed-link setup, we clear xpcs_an_inband */ 616 if (fwnode) { 617 struct fwnode_handle *fixed_node; 618 619 fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); 620 if (fixed_node) 621 plat->mdio_bus_data->xpcs_an_inband = false; 622 623 fwnode_handle_put(fixed_node); 624 } 625 626 /* Ensure mdio bus PHY-scan skips intel serdes and pcs-xpcs */ 627 plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; 628 plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; 629 630 plat->int_snapshot_num = AUX_SNAPSHOT1; 631 632 plat->crosststamp = intel_crosststamp; 633 plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN; 634 635 /* Setup MSI vector offset specific to Intel mGbE controller */ 636 plat->msi_mac_vec = 29; 637 plat->msi_lpi_vec = 28; 638 plat->msi_sfty_ce_vec = 27; 639 plat->msi_sfty_ue_vec = 26; 640 plat->msi_rx_base_vec = 0; 641 plat->msi_tx_base_vec = 1; 642 643 return 0; 644 645 err_alloc_info: > 646 clk_disable_unprepare(clk); 647 clk_unregister_fixed_rate(clk); 648 649 return ret; 650 } 651 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From lkp at intel.com Wed Dec 6 11:29:36 2023 From: lkp at intel.com (kernel test robot) Date: Wed, 6 Dec 2023 08:29:36 +0800 Subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" In-Reply-To: <20231205103559.9605-12-fancer.lancer@gmail.com> References: <20231205103559.9605-12-fancer.lancer@gmail.com> Message-ID: <202312060843.C3pV7P8b-lkp@intel.com> Hi Serge, kernel test robot noticed the following build warnings: [auto build test WARNING on net-next/main] url: https://github.com/intel-lab-lkp/linux/commits/Serge-Semin/net-pcs-xpcs-Drop-sentinel-entry-from-2500basex-ifaces-list/20231205-183808 base: net-next/main patch link: https://lore.kernel.org/r/20231205103559.9605-12-fancer.lancer%40gmail.com patch subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" config: x86_64-randconfig-006-20231206 (https://download.01.org/0day-ci/archive/20231206/202312060843.C3pV7P8b-lkp at intel.com/config) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060843.C3pV7P8b-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312060843.C3pV7P8b-lkp at intel.com/ All warnings (new ones prefixed by >>): drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c: In function 'txgbe_mdio_pcs_init': drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:150:9: error: implicit declaration of function 'xpcs_create_mdiodev'; did you mean 'xpcs_create_byaddr'? [-Werror=implicit-function-declaration] xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); ^~~~~~~~~~~~~~~~~~~ xpcs_create_byaddr >> drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:150:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion] xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); ^ cc1: some warnings being treated as errors vim +150 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c 854cace61387b6 Jiawen Wu 2023-06-06 121 854cace61387b6 Jiawen Wu 2023-06-06 122 static int txgbe_mdio_pcs_init(struct txgbe *txgbe) 854cace61387b6 Jiawen Wu 2023-06-06 123 { 854cace61387b6 Jiawen Wu 2023-06-06 124 struct mii_bus *mii_bus; 854cace61387b6 Jiawen Wu 2023-06-06 125 struct dw_xpcs *xpcs; 854cace61387b6 Jiawen Wu 2023-06-06 126 struct pci_dev *pdev; 854cace61387b6 Jiawen Wu 2023-06-06 127 struct wx *wx; 854cace61387b6 Jiawen Wu 2023-06-06 128 int ret = 0; 854cace61387b6 Jiawen Wu 2023-06-06 129 854cace61387b6 Jiawen Wu 2023-06-06 130 wx = txgbe->wx; 854cace61387b6 Jiawen Wu 2023-06-06 131 pdev = wx->pdev; 854cace61387b6 Jiawen Wu 2023-06-06 132 854cace61387b6 Jiawen Wu 2023-06-06 133 mii_bus = devm_mdiobus_alloc(&pdev->dev); 854cace61387b6 Jiawen Wu 2023-06-06 134 if (!mii_bus) 854cace61387b6 Jiawen Wu 2023-06-06 135 return -ENOMEM; 854cace61387b6 Jiawen Wu 2023-06-06 136 854cace61387b6 Jiawen Wu 2023-06-06 137 mii_bus->name = "txgbe_pcs_mdio_bus"; 854cace61387b6 Jiawen Wu 2023-06-06 138 mii_bus->read_c45 = &txgbe_pcs_read; 854cace61387b6 Jiawen Wu 2023-06-06 139 mii_bus->write_c45 = &txgbe_pcs_write; 854cace61387b6 Jiawen Wu 2023-06-06 140 mii_bus->parent = &pdev->dev; 854cace61387b6 Jiawen Wu 2023-06-06 141 mii_bus->phy_mask = ~0; 854cace61387b6 Jiawen Wu 2023-06-06 142 mii_bus->priv = wx; 854cace61387b6 Jiawen Wu 2023-06-06 143 snprintf(mii_bus->id, MII_BUS_ID_SIZE, "txgbe_pcs-%x", d8c21ef7b2b147 Xiongfeng Wang 2023-08-08 144 pci_dev_id(pdev)); 854cace61387b6 Jiawen Wu 2023-06-06 145 854cace61387b6 Jiawen Wu 2023-06-06 146 ret = devm_mdiobus_register(&pdev->dev, mii_bus); 854cace61387b6 Jiawen Wu 2023-06-06 147 if (ret) 854cace61387b6 Jiawen Wu 2023-06-06 148 return ret; 854cace61387b6 Jiawen Wu 2023-06-06 149 854cace61387b6 Jiawen Wu 2023-06-06 @150 xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); 854cace61387b6 Jiawen Wu 2023-06-06 151 if (IS_ERR(xpcs)) 854cace61387b6 Jiawen Wu 2023-06-06 152 return PTR_ERR(xpcs); 854cace61387b6 Jiawen Wu 2023-06-06 153 854cace61387b6 Jiawen Wu 2023-06-06 154 txgbe->xpcs = xpcs; 854cace61387b6 Jiawen Wu 2023-06-06 155 854cace61387b6 Jiawen Wu 2023-06-06 156 return 0; 854cace61387b6 Jiawen Wu 2023-06-06 157 } 854cace61387b6 Jiawen Wu 2023-06-06 158 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From patrick at stwcx.xyz Wed Dec 6 12:00:25 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Tue, 5 Dec 2023 19:00:25 -0600 Subject: [PATCH dev-5.6 1/3] net/ncsi: Simplify Kconfig/dts control flow In-Reply-To: <20231205234843.4013767-1-patrick@stwcx.xyz> References: <20231205234843.4013767-1-patrick@stwcx.xyz> Message-ID: On Tue, Dec 05, 2023 at 05:48:41PM -0600, Patrick Williams wrote: > (cherry picked from commit c797ce168930ce3d62a9b7fc4d7040963ee6a01e) These patches were cherry-picked from the net-next tree and thus are tentatively going into the 6.8 tree. I've applied them onto our 6.5 tree, but they should apply cleanly to 6.6 also. -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From jim.t90615 at gmail.com Wed Dec 6 12:45:27 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Wed, 6 Dec 2023 09:45:27 +0800 Subject: [PATCH v8 0/3] Add Nuvoton NPCM SGPIO feature Message-ID: <20231206014530.1600151-1-jim.t90615@gmail.com> This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). NPCM7xx/NPCM8xx have two sgpio module each module can support up to 64 output pins,and up to 64 input pin, the pin is only for GPI or GPO. GPIO pins have sequential, First half is GPO and second half is GPI. Jim Liu (3): dt-bindings: gpio: add NPCM sgpio driver bindings arm: dts: nuvoton: npcm: Add sgpio feature gpio: nuvoton: Add Nuvoton NPCM sgpio driver .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++ .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 + drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 637 ++++++++++++++++++ 5 files changed, 755 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml create mode 100644 drivers/gpio/gpio-npcm-sgpio.c -- 2.25.1 From jim.t90615 at gmail.com Wed Dec 6 12:45:28 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Wed, 6 Dec 2023 09:45:28 +0800 Subject: [PATCH v8 1/3] dt-bindings: gpio: add NPCM sgpio driver bindings In-Reply-To: <20231206014530.1600151-1-jim.t90615@gmail.com> References: <20231206014530.1600151-1-jim.t90615@gmail.com> Message-ID: <20231206014530.1600151-2-jim.t90615@gmail.com> Add dt-bindings document for the Nuvoton NPCM7xx sgpio driver Signed-off-by: Jim Liu Reviewed-by: Linus Walleij Reviewed-by: Rob Herring --- Changes for v8: - no changed Changes for v7: - no changed Changes for v6: - Drop quotes for $ref - Add and drop '|' for description - Add space after 'exposed.' - remove status --- .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml new file mode 100644 index 000000000000..84e0dbcb066c --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/nuvoton,sgpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton SGPIO controller + +maintainers: + - Jim LIU + +description: | + This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. + Nuvoton NPCM7xx SGPIO module is combine serial to parallel IC (HC595) + and parallel to serial IC (HC165), and use APB3 clock to control it. + This interface has 4 pins (D_out , D_in, S_CLK, LDSH). + NPCM7xx/NPCM8xx have two sgpio module each module can support up + to 64 output pins,and up to 64 input pin, the pin is only for gpi or gpo. + GPIO pins have sequential, First half is gpo and second half is gpi. + GPIO pins can be programmed to support the following options + - Support interrupt option for each input port and various interrupt + sensitivity option (level-high, level-low, edge-high, edge-low) + - ngpios is number of nuvoton,input-ngpios GPIO lines and nuvoton,output-ngpios GPIO lines. + nuvoton,input-ngpios GPIO lines is only for gpi. + nuvoton,output-ngpios GPIO lines is only for gpo. + +properties: + compatible: + enum: + - nuvoton,npcm750-sgpio + - nuvoton,npcm845-sgpio + + reg: + maxItems: 1 + + gpio-controller: true + + '#gpio-cells': + const: 2 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + nuvoton,input-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines is only for gpi. + minimum: 0 + maximum: 64 + + nuvoton,output-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines is only for gpo. + minimum: 0 + maximum: 64 + +required: + - compatible + - reg + - gpio-controller + - '#gpio-cells' + - interrupts + - nuvoton,input-ngpios + - nuvoton,output-ngpios + - clocks + +additionalProperties: false + +examples: + - | + #include + #include + gpio8: gpio at 101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + }; -- 2.25.1 From jim.t90615 at gmail.com Wed Dec 6 12:45:29 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Wed, 6 Dec 2023 09:45:29 +0800 Subject: [PATCH v8 2/3] arm: dts: nuvoton: npcm: Add sgpio feature In-Reply-To: <20231206014530.1600151-1-jim.t90615@gmail.com> References: <20231206014530.1600151-1-jim.t90615@gmail.com> Message-ID: <20231206014530.1600151-3-jim.t90615@gmail.com> Add the SGPIO controller to the NPCM7xx devicetree Signed-off-by: Jim Liu --- Changes for v8: - no changed Changes for v7: - no changed Changes for v6: - remove bus-frequency - check with dtbs_check --- .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi b/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi index 868454ae6bde..df91517a4842 100644 --- a/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi +++ b/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi @@ -372,6 +372,30 @@ &fanin12_pins &fanin13_pins status = "disabled"; }; + gpio8: gpio at 101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + + gpio9: gpio at 102000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x102000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + i2c0: i2c at 80000 { reg = <0x80000 0x1000>; compatible = "nuvoton,npcm750-i2c"; -- 2.25.1 From jim.t90615 at gmail.com Wed Dec 6 12:45:30 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Wed, 6 Dec 2023 09:45:30 +0800 Subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: <20231206014530.1600151-1-jim.t90615@gmail.com> References: <20231206014530.1600151-1-jim.t90615@gmail.com> Message-ID: <20231206014530.1600151-4-jim.t90615@gmail.com> Add Nuvoton BMC NPCM7xx/NPCM8xx sgpio driver support. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). BMC can use this driver to increase 64 GPI pins and 64 GPO pins to use. Signed-off-by: Jim Liu --- Changes for v8: - Remove OF_GPIO/GPIO_GENERIC and redundant assignments - Use GENMASK() and BIT() - Use dev_WARN and dev_err_probe - Check indentation issue - Use raw_spinlock_t Changes for v7: - Remove unused variable - Remove return in bank_reg function - Fix warning for const issue --- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 637 +++++++++++++++++++++++++++++++++ 3 files changed, 645 insertions(+) create mode 100644 drivers/gpio/gpio-npcm-sgpio.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b3a133ed31ee..efbdc93819d4 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -478,6 +478,13 @@ config GPIO_MXS select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_NPCM_SGPIO + bool "Nuvoton SGPIO support" + depends on ARCH_NPCM || COMPILE_TEST + select GPIOLIB_IRQCHIP + help + Say Y here to support Nuvoton NPCM7XX/NPCM8XX SGPIO functionality. + config GPIO_OCTEON tristate "Cavium OCTEON GPIO" depends on CAVIUM_OCTEON_SOC diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index eb73b5d633eb..373aa2943de5 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o +obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o diff --git a/drivers/gpio/gpio-npcm-sgpio.c b/drivers/gpio/gpio-npcm-sgpio.c new file mode 100644 index 000000000000..52dde726f175 --- /dev/null +++ b/drivers/gpio/gpio-npcm-sgpio.c @@ -0,0 +1,637 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Nuvoton NPCM Serial GPIO Driver + * + * Copyright (C) 2021 Nuvoton Technologies + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_NR_HW_SGPIO 64 + +#define NPCM_IOXCFG1 0x2A +#define NPCM_IOXCFG1_SFT_CLK GENMASK(3, 0) +#define NPCM_IOXCFG1_SCLK_POL BIT(4) +#define NPCM_IOXCFG1_LDSH_POL BIT(5) + +#define NPCM_IOXCTS 0x28 +#define NPCM_IOXCTS_IOXIF_EN BIT(7) +#define NPCM_IOXCTS_RD_MODE GENMASK(2, 1) +#define NPCM_IOXCTS_RD_MODE_PERIODIC BIT(2) + +#define NPCM_IOXCFG2 0x2B +#define NPCM_IOXCFG2_PORT GENMASK(3, 0) + +#define NPCM_IXOEVCFG_MASK GENMASK(1, 0) +#define NPCM_IXOEVCFG_FALLING BIT(1) +#define NPCM_IXOEVCFG_RISING BIT(0) +#define NPCM_IXOEVCFG_BOTH (NPCM_IXOEVCFG_FALLING | NPCM_IXOEVCFG_RISING) + +#define NPCM_CLK_MHZ 8000000 + +#define GPIO_BANK(x) ((x) / 8) +#define GPIO_BIT(x) ((x) % 8) + +/* + * Select the frequency of shift clock. + * The shift clock is a division of the APB clock. + */ +struct npcm_clk_cfg { + unsigned int *sft_clk; + unsigned int *clk_sel; + unsigned int cfg_opt; +}; + +struct npcm_sgpio { + struct gpio_chip chip; + struct clk *pclk; + struct irq_chip intc; + raw_spinlock_t lock; /*protect event config*/ + void __iomem *base; + int irq; + u8 nin_sgpio; + u8 nout_sgpio; + u8 in_port; + u8 out_port; + u8 int_type[MAX_NR_HW_SGPIO]; +}; + +struct npcm_sgpio_bank { + u8 rdata_reg; + u8 wdata_reg; + u8 event_config; + u8 event_status; +}; + +enum npcm_sgpio_reg { + READ_DATA, + WRITE_DATA, + EVENT_CFG, + EVENT_STS, +}; + +static const struct npcm_sgpio_bank npcm_sgpio_banks[] = { + { + .wdata_reg = 0x00, + .rdata_reg = 0x08, + .event_config = 0x10, + .event_status = 0x20, + }, + { + .wdata_reg = 0x01, + .rdata_reg = 0x09, + .event_config = 0x12, + .event_status = 0x21, + }, + { + .wdata_reg = 0x02, + .rdata_reg = 0x0a, + .event_config = 0x14, + .event_status = 0x22, + }, + { + .wdata_reg = 0x03, + .rdata_reg = 0x0b, + .event_config = 0x16, + .event_status = 0x23, + }, + { + .wdata_reg = 0x04, + .rdata_reg = 0x0c, + .event_config = 0x18, + .event_status = 0x24, + }, + { + .wdata_reg = 0x05, + .rdata_reg = 0x0d, + .event_config = 0x1a, + .event_status = 0x25, + }, + { + .wdata_reg = 0x06, + .rdata_reg = 0x0e, + .event_config = 0x1c, + .event_status = 0x26, + }, + { + .wdata_reg = 0x07, + .rdata_reg = 0x0f, + .event_config = 0x1e, + .event_status = 0x27, + }, + +}; + +static void __iomem *bank_reg(struct npcm_sgpio *gpio, + const struct npcm_sgpio_bank *bank, + const enum npcm_sgpio_reg reg) +{ + switch (reg) { + case READ_DATA: + return gpio->base + bank->rdata_reg; + case WRITE_DATA: + return gpio->base + bank->wdata_reg; + case EVENT_CFG: + return gpio->base + bank->event_config; + case EVENT_STS: + return gpio->base + bank->event_status; + default: + /* actually if code runs to here, it's an error case */ + dev_WARN(true, "Getting here is an error condition"); + } + return 0; +} + +static const struct npcm_sgpio_bank *offset_to_bank(unsigned int offset) +{ + unsigned int bank = GPIO_BANK(offset); + + return &npcm_sgpio_banks[bank]; +} + +static void irqd_to_npcm_sgpio_data(struct irq_data *d, + struct npcm_sgpio **gpio, + const struct npcm_sgpio_bank **bank, + u8 *bit, unsigned int *offset) +{ + struct npcm_sgpio *internal; + + *offset = irqd_to_hwirq(d); + internal = irq_data_get_irq_chip_data(d); + + *gpio = internal; + *offset -= internal->nout_sgpio; + *bank = offset_to_bank(*offset); + *bit = GPIO_BIT(*offset); +} + +static int npcm_sgpio_init_port(struct npcm_sgpio *gpio) +{ + u8 in_port, out_port, set_port, reg; + + in_port = GPIO_BANK(gpio->nin_sgpio); + if (GPIO_BIT(gpio->nin_sgpio) > 0) + in_port += 1; + + out_port = GPIO_BANK(gpio->nout_sgpio); + if (GPIO_BIT(gpio->nout_sgpio) > 0) + out_port += 1; + + gpio->in_port = in_port; + gpio->out_port = out_port; + set_port = ((out_port & NPCM_IOXCFG2_PORT) << 4) | (in_port & NPCM_IOXCFG2_PORT); + iowrite8(set_port, gpio->base + NPCM_IOXCFG2); + + reg = ioread8(gpio->base + NPCM_IOXCFG2); + + return reg == set_port ? 0 : -EINVAL; + +} + +static int npcm_sgpio_dir_in(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + return offset < gpio->nout_sgpio ? -EINVAL : 0; + +} + +static int npcm_sgpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + gc->set(gc, offset, val); + + return 0; + +} + +static int npcm_sgpio_get_direction(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + if (offset > gpio->chip.ngpio) + return -EINVAL; + + if (offset < gpio->nout_sgpio) + return GPIO_LINE_DIRECTION_OUT; + + return GPIO_LINE_DIRECTION_IN; +} + +static void npcm_sgpio_set(struct gpio_chip *gc, unsigned int offset, int val) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + const struct npcm_sgpio_bank *bank = offset_to_bank(offset); + void __iomem *addr; + u8 reg = 0; + + addr = bank_reg(gpio, bank, WRITE_DATA); + reg = ioread8(addr); + + if (val) + reg |= (val << GPIO_BIT(offset)); + else + reg &= ~(1 << GPIO_BIT(offset)); + + iowrite8(reg, addr); +} + +static int npcm_sgpio_get(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + const struct npcm_sgpio_bank *bank; + void __iomem *addr; + u8 reg; + int dir; + + dir = npcm_sgpio_get_direction(gc, offset); + if (dir == 0) { + bank = offset_to_bank(offset); + + addr = bank_reg(gpio, bank, WRITE_DATA); + reg = ioread8(addr); + reg = !!(reg & GPIO_BIT(offset)); + } else { + offset -= gpio->nout_sgpio; + bank = offset_to_bank(offset); + + addr = bank_reg(gpio, bank, READ_DATA); + reg = ioread8(addr); + reg = !!(reg & GPIO_BIT(offset)); + } + + return reg; +} + +static void npcm_sgpio_setup_enable(struct npcm_sgpio *gpio, bool enable) +{ + u8 reg = 0; + + reg = ioread8(gpio->base + NPCM_IOXCTS); + reg = reg & ~NPCM_IOXCTS_RD_MODE; + reg = reg | NPCM_IOXCTS_RD_MODE_PERIODIC; + + if (enable) { + reg |= NPCM_IOXCTS_IOXIF_EN; + iowrite8(reg, gpio->base + NPCM_IOXCTS); + } else { + reg &= ~NPCM_IOXCTS_IOXIF_EN; + iowrite8(reg, gpio->base + NPCM_IOXCTS); + } +} + +static int npcm_sgpio_setup_clk(struct npcm_sgpio *gpio, + const struct npcm_clk_cfg *clk_cfg) +{ + unsigned long apb_freq; + u32 val; + u8 tmp; + int i; + + apb_freq = clk_get_rate(gpio->pclk); + tmp = ioread8(gpio->base + NPCM_IOXCFG1) & ~NPCM_IOXCFG1_SFT_CLK; + + for (i = 0; i < clk_cfg->cfg_opt; i++) { + val = apb_freq / clk_cfg->sft_clk[i]; + if ((NPCM_CLK_MHZ < val) && (i != 0) ) { + iowrite8(clk_cfg->clk_sel[i-1] | tmp, gpio->base + NPCM_IOXCFG1); + return 0; + } else if (i == (clk_cfg->cfg_opt-1) && (NPCM_CLK_MHZ > val)) { + iowrite8(clk_cfg->clk_sel[i] | tmp, gpio->base + NPCM_IOXCFG1); + return 0; + } + } + + return -EINVAL; +} + +static void npcm_sgpio_irq_init_valid_mask(struct gpio_chip *gc, + unsigned long *valid_mask, unsigned int ngpios) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + int n = gpio->nin_sgpio; + + /* input GPIOs in the high range */ + bitmap_set(valid_mask, gpio->nout_sgpio, n); + bitmap_clear(valid_mask, 0, gpio->nout_sgpio); +} + +static void npcm_sgpio_irq_set_mask(struct irq_data *d, bool set) +{ + const struct npcm_sgpio_bank *bank; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *addr; + unsigned int offset; + u16 reg, type; + u8 bit; + + irqd_to_npcm_sgpio_data(d, &gpio, &bank, &bit, &offset); + addr = bank_reg(gpio, bank, EVENT_CFG); + + raw_spin_lock_irqsave(&gpio->lock, flags); + + npcm_sgpio_setup_enable(gpio, false); + + reg = ioread16(addr); + if (set) { + reg &= ~(NPCM_IXOEVCFG_MASK << (bit * 2)); + } else { + type = gpio->int_type[offset]; + reg |= (type << (bit * 2)); + } + + iowrite16(reg, addr); + + npcm_sgpio_setup_enable(gpio, true); + + addr = bank_reg(gpio, bank, EVENT_STS); + reg = ioread8(addr); + reg |= BIT(bit); + iowrite8(reg, addr); + + raw_spin_unlock_irqrestore(&gpio->lock, flags); +} + +static void npcm_sgpio_irq_ack(struct irq_data *d) +{ + const struct npcm_sgpio_bank *bank; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *status_addr; + unsigned int offset; + u8 bit; + + irqd_to_npcm_sgpio_data(d, &gpio, &bank, &bit, &offset); + status_addr = bank_reg(gpio, bank, EVENT_STS); + raw_spin_lock_irqsave(&gpio->lock, flags); + iowrite8(BIT(bit), status_addr); + raw_spin_unlock_irqrestore(&gpio->lock, flags); +} + +static void npcm_sgpio_irq_mask(struct irq_data *d) +{ + npcm_sgpio_irq_set_mask(d, true); +} + +static void npcm_sgpio_irq_unmask(struct irq_data *d) +{ + npcm_sgpio_irq_set_mask(d, false); +} + +static int npcm_sgpio_set_type(struct irq_data *d, unsigned int type) +{ + const struct npcm_sgpio_bank *bank; + irq_flow_handler_t handler; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *addr; + unsigned int offset; + u16 reg, val; + u8 bit; + + irqd_to_npcm_sgpio_data(d, &gpio, &bank, &bit, &offset); + + switch (type & IRQ_TYPE_SENSE_MASK) { + case IRQ_TYPE_EDGE_BOTH: + val = NPCM_IXOEVCFG_BOTH; + handler = handle_edge_irq; + break; + case IRQ_TYPE_EDGE_RISING: + val = NPCM_IXOEVCFG_RISING; + handler = handle_edge_irq; + break; + case IRQ_TYPE_EDGE_FALLING: + val = NPCM_IXOEVCFG_FALLING; + handler = handle_edge_irq; + break; + case IRQ_TYPE_LEVEL_HIGH: + val = NPCM_IXOEVCFG_RISING; + handler = handle_level_irq; + break; + case IRQ_TYPE_LEVEL_LOW: + val = NPCM_IXOEVCFG_FALLING; + handler = handle_level_irq; + break; + default: + return -EINVAL; + } + + gpio->int_type[offset] = val; + + raw_spin_lock_irqsave(&gpio->lock, flags); + npcm_sgpio_setup_enable(gpio, false); + addr = bank_reg(gpio, bank, EVENT_CFG); + reg = ioread16(addr); + + reg |= (val << (bit * 2)); + + iowrite16(reg, addr); + npcm_sgpio_setup_enable(gpio, true); + raw_spin_unlock_irqrestore(&gpio->lock, flags); + + irq_set_handler_locked(d, handler); + + return 0; +} + +static void npcm_sgpio_irq_handler(struct irq_desc *desc) +{ + struct gpio_chip *gc = irq_desc_get_handler_data(desc); + struct irq_chip *ic = irq_desc_get_chip(desc); + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + unsigned int i, j, girq; + unsigned long reg; + + chained_irq_enter(ic, desc); + + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; + + reg = ioread8(bank_reg(gpio, bank, EVENT_STS)); + for_each_set_bit(j, ®, 8) { + girq = irq_find_mapping(gc->irq.domain, i * 8 + gpio->nout_sgpio + j); + generic_handle_irq(girq); + } + } + + chained_irq_exit(ic, desc); +} + +static const struct irq_chip sgpio_irq_chip = { + .name = "sgpio-irq", + .irq_ack = npcm_sgpio_irq_ack, + .irq_mask = npcm_sgpio_irq_mask, + .irq_unmask = npcm_sgpio_irq_unmask, + .irq_set_type = npcm_sgpio_set_type, + .flags = IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + +static int npcm_sgpio_setup_irqs(struct npcm_sgpio *gpio, + struct platform_device *pdev) +{ + int rc, i; + struct gpio_irq_chip *irq; + + rc = platform_get_irq(pdev, 0); + if (rc < 0) + return rc; + + gpio->irq = rc; + + npcm_sgpio_setup_enable(gpio, false); + + /* Disable IRQ and clear Interrupt status registers for all SGPIO Pins. */ + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; + + iowrite16(0x0000, bank_reg(gpio, bank, EVENT_CFG)); + iowrite8(0xff, bank_reg(gpio, bank, EVENT_STS)); + } + + irq = &gpio->chip.irq; + gpio_irq_chip_set_chip(irq, &sgpio_irq_chip); + irq->init_valid_mask = npcm_sgpio_irq_init_valid_mask; + irq->handler = handle_bad_irq; + irq->default_type = IRQ_TYPE_NONE; + irq->parent_handler = npcm_sgpio_irq_handler; + irq->parent_handler_data = gpio; + irq->parents = &gpio->irq; + irq->num_parents = 1; + + return 0; +} + +static const unsigned int npcm750_SFT_CLK[] = { + 1024, 32, 8, 4, 3, 2, +}; + +static const unsigned int npcm750_CLK_SEL[] = { + 0x00, 0x05, 0x07, 0x0C, 0x0D, 0x0E, +}; + +static const unsigned int npcm845_SFT_CLK[] = { + 1024, 32, 16, 8, 4, +}; + +static const unsigned int npcm845_CLK_SEL[] = { + 0x00, 0x05, 0x06, 0x07, 0x0C, +}; + +static const struct npcm_clk_cfg npcm750_sgpio_pdata = { + .sft_clk = npcm750_SFT_CLK, + .clk_sel = npcm750_CLK_SEL, + .cfg_opt = 6, +}; + +static const struct npcm_clk_cfg npcm845_sgpio_pdata = { + .sft_clk = npcm845_SFT_CLK, + .clk_sel = npcm845_CLK_SEL, + .cfg_opt = 5, +}; + +static const struct of_device_id npcm_sgpio_of_table[] = { + { .compatible = "nuvoton,npcm750-sgpio", .data = &npcm750_sgpio_pdata, }, + { .compatible = "nuvoton,npcm845-sgpio", .data = &npcm845_sgpio_pdata, }, + {} +}; +MODULE_DEVICE_TABLE(of, npcm_sgpio_of_table); + +static int npcm_sgpio_probe(struct platform_device *pdev) +{ + struct npcm_sgpio *gpio; + const struct npcm_clk_cfg *clk_cfg; + int rc; + u32 nin_gpios, nout_gpios; + + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); + if (!gpio) + return -ENOMEM; + + gpio->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(gpio->base)) + return PTR_ERR(gpio->base); + + clk_cfg = device_get_match_data(&pdev->dev); + if (!clk_cfg) + return -EINVAL; + + rc = device_property_read_u32(&pdev->dev, "nuvoton,input-ngpios", &nin_gpios); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Could not read ngpios property\n"); + + rc = device_property_read_u32(&pdev->dev, "nuvoton,output-ngpios", &nout_gpios); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Could not read ngpios property\n"); + + gpio->nin_sgpio = nin_gpios; + gpio->nout_sgpio = nout_gpios; + if (gpio->nin_sgpio > MAX_NR_HW_SGPIO || gpio->nout_sgpio > MAX_NR_HW_SGPIO) { + dev_err(&pdev->dev, "Number of GPIOs exceeds the maximum of %d: input: %d output: %d\n", + MAX_NR_HW_SGPIO, nin_gpios, nout_gpios); + return -EINVAL; + } + + gpio->pclk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(gpio->pclk)) { + dev_err(&pdev->dev, "Could not get pclk\n"); + return PTR_ERR(gpio->pclk); + } + + rc = npcm_sgpio_setup_clk(gpio, clk_cfg); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Failed to setup clock\n"); + + raw_spin_lock_init(&gpio->lock); + gpio->chip.parent = &pdev->dev; + gpio->chip.ngpio = gpio->nin_sgpio + gpio->nout_sgpio; + gpio->chip.direction_input = npcm_sgpio_dir_in; + gpio->chip.direction_output = npcm_sgpio_dir_out; + gpio->chip.get_direction = npcm_sgpio_get_direction; + gpio->chip.get = npcm_sgpio_get; + gpio->chip.set = npcm_sgpio_set; + gpio->chip.label = dev_name(&pdev->dev); + gpio->chip.base = -1; + + rc = npcm_sgpio_init_port(gpio); + if (rc < 0) + return rc; + + rc = npcm_sgpio_setup_irqs(gpio, pdev); + if (rc < 0) + return rc; + + rc = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); + if (rc < 0) + return rc; + + npcm_sgpio_setup_enable(gpio, true); + + return 0; +} + +static struct platform_driver npcm_sgpio_driver = { + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = npcm_sgpio_of_table, + }, + .probe = npcm_sgpio_probe, +}; +module_platform_driver(npcm_sgpio_driver); + +MODULE_AUTHOR("Jim Liu "); +MODULE_AUTHOR("Joseph Liu "); +MODULE_DESCRIPTION("Nuvoton NPCM Serial GPIO Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 From zev at bewilderbeest.net Wed Dec 6 13:37:40 2023 From: zev at bewilderbeest.net (Zev Weiss) Date: Tue, 5 Dec 2023 18:37:40 -0800 Subject: [PATCH linux dev-6.5 4/4] ARM: dts: aspeed: Add ASRock E3C256D4I BMC In-Reply-To: <20231206023742.5242-6-zev@bewilderbeest.net> References: <20231206023742.5242-6-zev@bewilderbeest.net> Message-ID: <20231206023742.5242-10-zev@bewilderbeest.net> Like the E3C246D4I, this is a reasonably affordable off-the-shelf mini-ITX AST2500/Xeon motherboard with good potential as an OpenBMC development platform. Booting the host requires a modicum of eSPI support that's not yet in the mainline kernel, but most other basic BMC functionality is available with this device-tree. Signed-off-by: Zev Weiss Link: https://lore.kernel.org/r/20231114112722.28506-6-zev at bewilderbeest.net Signed-off-by: Joel Stanley (cherry picked from commit e9be9b34b841d2b1691c285ef0e85232734e28b2) --- arch/arm/boot/dts/aspeed/Makefile | 1 + .../aspeed/aspeed-bmc-asrock-e3c256d4i.dts | 316 ++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-e3c256d4i.dts diff --git a/arch/arm/boot/dts/aspeed/Makefile b/arch/arm/boot/dts/aspeed/Makefile index 61dbb908c74e..450d28641496 100644 --- a/arch/arm/boot/dts/aspeed/Makefile +++ b/arch/arm/boot/dts/aspeed/Makefile @@ -9,6 +9,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += \ aspeed-bmc-ampere-mtmitchell.dtb \ aspeed-bmc-arm-stardragon4800-rep2.dtb \ aspeed-bmc-asrock-e3c246d4i.dtb \ + aspeed-bmc-asrock-e3c256d4i.dtb \ aspeed-bmc-asrock-romed8hm3.dtb \ aspeed-bmc-asrock-spc621d8hm3.dtb \ aspeed-bmc-bytedance-g220a.dtb \ diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-e3c256d4i.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-e3c256d4i.dts new file mode 100644 index 000000000000..64796fb82032 --- /dev/null +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-e3c256d4i.dts @@ -0,0 +1,316 @@ +// SPDX-License-Identifier: GPL-2.0+ +/dts-v1/; + +#include "aspeed-g5.dtsi" +#include +#include +#include +#include + +/{ + model = "ASRock E3C256D4I BMC"; + compatible = "asrock,e3c256d4i-bmc", "aspeed,ast2500"; + + aliases { + serial4 = &uart5; + + i2c20 = &i2c2mux0ch0; + i2c21 = &i2c2mux0ch1; + i2c22 = &i2c2mux0ch2; + i2c23 = &i2c2mux0ch3; + }; + + chosen { + stdout-path = &uart5; + bootargs = "console=tty0 console=ttyS4,115200 earlycon"; + }; + + memory at 80000000 { + reg = <0x80000000 0x20000000>; + }; + + leds { + compatible = "gpio-leds"; + + heartbeat { + gpios = <&gpio ASPEED_GPIO(H, 6) GPIO_ACTIVE_LOW>; + linux,default-trigger = "timer"; + }; + + system-fault { + gpios = <&gpio ASPEED_GPIO(Z, 2) GPIO_ACTIVE_LOW>; + panic-indicator; + }; + }; + + iio-hwmon { + compatible = "iio-hwmon"; + io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>, + <&adc 4>, <&adc 5>, <&adc 6>, <&adc 7>, + <&adc 8>, <&adc 9>, <&adc 10>, <&adc 11>, + <&adc 12>, <&adc 13>, <&adc 14>, <&adc 15>; + }; +}; + +&fmc { + status = "okay"; + flash at 0 { + status = "okay"; + m25p,fast-read; + label = "bmc"; + spi-max-frequency = <100000000>; /* 100 MHz */ +#include "openbmc-flash-layout-64.dtsi" + }; +}; + +&uart1 { + status = "okay"; +}; + +&uart2 { + status = "okay"; +}; + +&uart3 { + status = "okay"; +}; + +&uart4 { + status = "okay"; +}; + +&uart5 { + status = "okay"; +}; + +&uart_routing { + status = "okay"; +}; + +&mac0 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rgmii1_default &pinctrl_mdio1_default>; + + nvmem-cells = <ð0_macaddress>; + nvmem-cell-names = "mac-address"; +}; + +&i2c0 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; +}; + +&i2c2 { + status = "okay"; + + i2c-mux at 70 { + compatible = "nxp,pca9545"; + reg = <0x70>; + #address-cells = <1>; + #size-cells = <0>; + + i2c2mux0ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + + i2c2mux0ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + + i2c2mux0ch2: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + }; + + i2c2mux0ch3: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + }; + }; +}; + +&i2c3 { + status = "okay"; +}; + +&i2c4 { + status = "okay"; +}; + +&i2c5 { + status = "okay"; +}; + +&i2c6 { + status = "okay"; +}; + +&i2c7 { + status = "okay"; +}; + +&i2c9 { + status = "okay"; +}; + +&i2c10 { + status = "okay"; +}; + +&i2c11 { + status = "okay"; + + vrm at 60 { + compatible = "renesas,isl69269", "isl69269"; + reg = <0x60>; + }; +}; + +&i2c12 { + status = "okay"; + + /* FRU eeprom */ + eeprom at 57 { + compatible = "st,24c128", "atmel,24c128"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x57>; + pagesize = <16>; + + eth0_macaddress: macaddress at 3f80 { + reg = <0x3f80 6>; + }; + }; +}; + +&video { + status = "okay"; +}; + +&vhub { + status = "okay"; +}; + +&lpc_ctrl { + status = "okay"; +}; + +&lpc_snoop { + status = "okay"; + snoop-ports = <0x80>; +}; + +&kcs3 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; +}; + +&peci0 { + status = "okay"; +}; + +&wdt1 { + aspeed,reset-mask = <(AST2500_WDT_RESET_DEFAULT & ~AST2500_WDT_RESET_LPC)>; +}; + +&wdt2 { + aspeed,reset-mask = <(AST2500_WDT_RESET_DEFAULT & ~AST2500_WDT_RESET_LPC)>; +}; + +&pwm_tacho { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default /* CPU */ + &pinctrl_pwm2_default /* rear */ + &pinctrl_pwm4_default>; /* front */ + + /* CPU */ + fan at 0 { + reg = <0x00>; + aspeed,fan-tach-ch = /bits/ 8 <0x00>; + }; + + /* rear */ + fan at 2 { + reg = <0x02>; + aspeed,fan-tach-ch = /bits/ 8 <0x02>; + }; + + /* front */ + fan at 4 { + reg = <0x04>; + aspeed,fan-tach-ch = /bits/ 8 <0x04>; + }; +}; + +&gpio { + status = "okay"; + gpio-line-names = + /* A */ "", "", "NMI_BTN_N", "BMC_NMI", "", "", "", "", + /* B */ "", "", "", "", "", "", "", "", + /* C */ "", "", "", "", "", "", "", "", + /* D */ "BMC_PSIN", "BMC_PSOUT", "BMC_RESETCON", "RESETCON", + "", "", "", "", + /* E */ "", "", "", "", "", "", "", "", + /* F */ "LOCATORLED_STATUS_N", "LOCATORBTN", "", "", + "", "", "BMC_PCH_SCI_LPC", "BMC_NCSI_MUX_CTL", + /* G */ "HWM_BAT_EN", "CHASSIS_ID0", "CHASSIS_ID1", "CHASSIS_ID2", + "", "", "", "", + /* H */ "FM_ME_RCVR_N", "O_PWROK", "", "D4_DIMM_EVENT_3V_N", + "MFG_MODE_N", "BMC_RTCRST", "BMC_HB_LED_N", "BMC_CASEOPEN", + /* I */ "", "", "", "", "", "", "", "", + /* J */ "BMC_READY", "BMC_PCH_BIOS_CS_N", "BMC_SMI", "", "", "", "", "", + /* K */ "", "", "", "", "", "", "", "", + /* L */ "", "", "", "", "", "", "", "", + /* M */ "", "", "", "", "", "", "", "", + /* N */ "", "", "", "", "", "", "", "", + /* O */ "", "", "", "", "", "", "", "", + /* P */ "", "", "", "", "", "", "", "", + /* Q */ "", "", "", "", "", "", "", "", + /* R */ "", "", "", "", "", "", "", "", + /* S */ "PCHHOT_BMC_N", "", "RSMRST", "", "", "", "", "", + /* T */ "", "", "", "", "", "", "", "", + /* U */ "", "", "", "", "", "", "", "", + /* V */ "", "", "", "", "", "", "", "", + /* W */ "", "", "", "", "", "", "", "", + /* X */ "", "", "", "", "", "", "", "", + /* Y */ "SLP_S3", "SLP_S5", "", "", "", "", "", "", + /* Z */ "CPU_CATERR_BMC_N", "", "SYSTEM_FAULT_LED_N", "BMC_THROTTLE_N", + "", "", "", "", + /* AA */ "CPU1_THERMTRIP_LATCH_N", "", "CPU1_PROCHOT_N", "", + "", "", "IRQ_SMI_ACTIVE_N", "FM_BIOS_POST_CMPLT_N", + /* AB */ "", "", "ME_OVERRIDE", "BMC_DMI_MODIFY", "", "", "", "", + /* AC */ "", "", "", "", "", "", "", ""; +}; + +&adc { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc0_default /* 3VSB */ + &pinctrl_adc1_default /* 5VSB */ + &pinctrl_adc2_default /* CPU1 */ + &pinctrl_adc3_default /* VCCSA */ + &pinctrl_adc4_default /* VCCM */ + &pinctrl_adc5_default /* V10M */ + &pinctrl_adc6_default /* VCCIO */ + &pinctrl_adc7_default /* VCCGT */ + &pinctrl_adc8_default /* VPPM */ + &pinctrl_adc9_default /* BAT */ + &pinctrl_adc10_default /* 3V */ + &pinctrl_adc11_default /* 5V */ + &pinctrl_adc12_default /* 12V */ + &pinctrl_adc13_default /* GND */ + &pinctrl_adc14_default /* GND */ + &pinctrl_adc15_default>; /* GND */ +}; -- 2.43.0 From zev at bewilderbeest.net Wed Dec 6 13:37:36 2023 From: zev at bewilderbeest.net (Zev Weiss) Date: Tue, 5 Dec 2023 18:37:36 -0800 Subject: [PATCH linux dev-6.5 0/4] Add device trees for ASrock E3C256D4I & SPC621D8HM3 Message-ID: <20231206023742.5242-6-zev@bewilderbeest.net> Hello, These patches add support for the BMCs on the ASRock e3c256d4i and spc621d8hm3 boards. All four patches are currently in the 'for-next' branch of Joel's bmc.git tree. I used the '-x' flag when cherry-picking them onto the dev-6.5 branch, but since they're not yet actually merged into the mainline kernel I suppose it's possible the upstream commit hashes might still change, so feel free to drop those tags as preferred. [Mistakenly didn't CC the list on first send, apologies for the duplication Joel & Andrew.] Thanks, Zev Zev Weiss (4): dt-bindings: arm: aspeed: document ASRock SPC621D8HM3 ARM: dts: aspeed: Add ASRock SPC621D8HM3 BMC dt-bindings: arm: aspeed: document ASRock E3C256D4I ARM: dts: aspeed: Add ASRock E3C256D4I BMC .../bindings/arm/aspeed/aspeed.yaml | 2 + arch/arm/boot/dts/aspeed/Makefile | 2 + .../aspeed/aspeed-bmc-asrock-e3c256d4i.dts | 316 +++++++++++++++++ .../aspeed/aspeed-bmc-asrock-spc621d8hm3.dts | 318 ++++++++++++++++++ 4 files changed, 638 insertions(+) create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-e3c256d4i.dts create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-spc621d8hm3.dts -- 2.43.0 From zev at bewilderbeest.net Wed Dec 6 13:37:38 2023 From: zev at bewilderbeest.net (Zev Weiss) Date: Tue, 5 Dec 2023 18:37:38 -0800 Subject: [PATCH linux dev-6.5 2/4] ARM: dts: aspeed: Add ASRock SPC621D8HM3 BMC In-Reply-To: <20231206023742.5242-6-zev@bewilderbeest.net> References: <20231206023742.5242-6-zev@bewilderbeest.net> Message-ID: <20231206023742.5242-8-zev@bewilderbeest.net> This is a Xeon board broadly similar (aside from CPU vendor) to the already-support romed8hm3 (half-width, single-socket, ast2500). It doesn't require anything terribly special for OpenBMC support, so this device-tree should provide everything necessary for basic functionality with it. Signed-off-by: Zev Weiss Link: https://lore.kernel.org/r/20231114112819.28572-6-zev at bewilderbeest.net Signed-off-by: Joel Stanley (cherry picked from commit 0d7c840545b4757b4e2d66d690b657561d250a35) --- arch/arm/boot/dts/aspeed/Makefile | 1 + .../aspeed/aspeed-bmc-asrock-spc621d8hm3.dts | 318 ++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-spc621d8hm3.dts diff --git a/arch/arm/boot/dts/aspeed/Makefile b/arch/arm/boot/dts/aspeed/Makefile index 23cbc7203a8e..61dbb908c74e 100644 --- a/arch/arm/boot/dts/aspeed/Makefile +++ b/arch/arm/boot/dts/aspeed/Makefile @@ -10,6 +10,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += \ aspeed-bmc-arm-stardragon4800-rep2.dtb \ aspeed-bmc-asrock-e3c246d4i.dtb \ aspeed-bmc-asrock-romed8hm3.dtb \ + aspeed-bmc-asrock-spc621d8hm3.dtb \ aspeed-bmc-bytedance-g220a.dtb \ aspeed-bmc-delta-ahe50dc.dtb \ aspeed-bmc-facebook-bletchley.dtb \ diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-spc621d8hm3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-spc621d8hm3.dts new file mode 100644 index 000000000000..e77435fdb3b1 --- /dev/null +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-asrock-spc621d8hm3.dts @@ -0,0 +1,318 @@ +// SPDX-License-Identifier: GPL-2.0+ +/dts-v1/; + +#include "aspeed-g5.dtsi" +#include +#include +#include + +/{ + model = "ASRock SPC621D8HM3 BMC"; + compatible = "asrock,spc621d8hm3-bmc", "aspeed,ast2500"; + + aliases { + serial4 = &uart5; + + i2c20 = &i2c1mux0ch0; + i2c21 = &i2c1mux0ch1; + }; + + chosen { + stdout-path = &uart5; + bootargs = "console=tty0 console=ttyS4,115200 earlycon"; + }; + + memory at 80000000 { + reg = <0x80000000 0x20000000>; + }; + + leds { + compatible = "gpio-leds"; + + heartbeat { + gpios = <&gpio ASPEED_GPIO(H, 6) GPIO_ACTIVE_LOW>; + linux,default-trigger = "timer"; + }; + + system-fault { + gpios = <&gpio ASPEED_GPIO(Z, 2) GPIO_ACTIVE_LOW>; + panic-indicator; + }; + }; + + iio-hwmon { + compatible = "iio-hwmon"; + io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>, + <&adc 4>, <&adc 5>, <&adc 6>, <&adc 7>, + <&adc 8>, <&adc 9>, <&adc 10>, <&adc 11>, + <&adc 12>, <&adc 13>, <&adc 14>, <&adc 15>; + }; +}; + +&fmc { + status = "okay"; + flash at 0 { + status = "okay"; + m25p,fast-read; + label = "bmc"; + spi-max-frequency = <50000000>; /* 50 MHz */ +#include "openbmc-flash-layout-64.dtsi" + }; +}; + +&uart5 { + status = "okay"; +}; + +&vuart { + status = "okay"; + aspeed,lpc-io-reg = <0x2f8>; + aspeed,lpc-interrupts = <3 IRQ_TYPE_LEVEL_HIGH>; +}; + +&mac0 { + status = "okay"; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rgmii1_default &pinctrl_mdio1_default>; + + nvmem-cells = <ð0_macaddress>; + nvmem-cell-names = "mac-address"; +}; + +&i2c0 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; + + /* hardware monitor/thermal sensor */ + temperature-sensor at 29 { + compatible = "nuvoton,nct7802"; + reg = <0x29>; + }; + + /* motherboard temp sensor (TMP1, near BMC) */ + temperature-sensor at 4c { + compatible = "nuvoton,w83773g"; + reg = <0x4c>; + }; + + /* motherboard FRU eeprom */ + eeprom at 50 { + compatible = "st,24c128", "atmel,24c128"; + #address-cells = <1>; + #size-cells = <1>; + reg = <0x50>; + pagesize = <16>; + + eth0_macaddress: macaddress at 3f80 { + reg = <0x3f80 6>; + }; + }; + + /* M.2 slot smbus mux */ + i2c-mux at 71 { + compatible = "nxp,pca9545"; + reg = <0x71>; + #address-cells = <1>; + #size-cells = <0>; + + i2c1mux0ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + + i2c1mux0ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; +}; + +&i2c2 { + status = "okay"; +}; + +&i2c3 { + status = "okay"; +}; + +&i2c4 { + status = "okay"; +}; + +&i2c5 { + status = "okay"; +}; + +&i2c6 { + status = "okay"; +}; + +&i2c7 { + status = "okay"; +}; + +&i2c8 { + status = "okay"; +}; + +&i2c9 { + status = "okay"; +}; + +&i2c10 { + status = "okay"; +}; + +&i2c11 { + status = "okay"; +}; + +&i2c12 { + status = "okay"; +}; + +&i2c13 { + status = "okay"; +}; + +&video { + status = "okay"; +}; + +&vhub { + status = "okay"; +}; + +&lpc_ctrl { + status = "okay"; +}; + +&lpc_snoop { + status = "okay"; + snoop-ports = <0x80>; +}; + +&kcs3 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; +}; + +&peci0 { + status = "okay"; +}; + +&pwm_tacho { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pwm0_default + &pinctrl_pwm2_default + &pinctrl_pwm3_default + &pinctrl_pwm4_default>; + + fan at 0 { + reg = <0x00>; + aspeed,fan-tach-ch = /bits/ 8 <0x00>; + }; + + fan at 2 { + reg = <0x02>; + aspeed,fan-tach-ch = /bits/ 8 <0x02>; + }; + + fan at 3 { + reg = <0x03>; + aspeed,fan-tach-ch = /bits/ 8 <0x03>; + }; + + fan at 4 { + reg = <0x04>; + aspeed,fan-tach-ch = /bits/ 8 <0x04>; + }; +}; + +&gpio { + status = "okay"; + gpio-line-names = + /* A */ "LOCATORLED_STATUS_N", "LOCATORBTN_N", + "BMC_READY_N", "FM_SPD_DDRCPU_LVLSHFT_EN", + "", "", "", "", + /* B */ "NODE_ID_1", "NODE_ID_2", "PSU_FAN_FAIL_N", "", + "", "", "", "GPIO_RST", + /* C */ "", "", "", "", "", "", "", "", + /* D */ "FP_PWR_BTN_MUX_N", "FM_BMC_PWRBTN_OUT_N", + "FP_RST_BTN_N", "RST_BMC_RSTBTN_OUT_N", + "NMI_BTN_N", "BMC_NMI", + "", "", + /* E */ "", "", "", "FM_ME_RCVR_N", "", "", "", "", + /* F */ "BMC_SMB_SEL_N", "FM_CPU2_DISABLE_COD_N", + "FM_REMOTE_DEBUG_BMC_EN", "FM_CPU_ERR0_LVT3_EN", + "FM_CPU_ERR1_LVT3_EN", "FM_CPU_ERR2_LVT3_EN", + "FM_MEM_THERM_EVENT_CPU1_LVT3_N", "FM_MEM_THERM_EVENT_CPU2_LVT3_N", + /* G */ "HWM_BAT_EN", "", "BMC_PHYRST_N", "FM_BIOS_SPI_BMC_CTRL", + "BMC_ALERT1_N", "BMC_ALERT2_N", "BMC_ALERT3_N", "IRQ_SML0_ALERT_N", + /* H */ "BMC_SMB_PRESENT_1_N", "FM_PCH_CORE_VID_0", "FM_PCH_CORE_VID_1", "", + "FM_MFG_MODE", "BMC_RTCRST", "BMC_HB_LED_N", "BMC_CASEOPEN", + /* I */ "IRQ_PVDDQ_ABCD_CPU1_VRHOT_LVC3_N", "IRQ_PVDDQ_ABCD_CPU2_VRHOT_LVC3_N", + "IRQ_PVDDQ_EFGH_CPU1_VRHOT_LVC3_N", "IRQ_PVDDQ_EFGH_CPU2_VRHOT_LVC3_N", + "", "", "", "", + /* J */ "", "", "", "", "", "", "", "", + /* K */ "", "", "", "", "", "", "", "", + /* L */ "", "", "", "", "", "", "", "", + /* M */ "FM_PVCCIN_CPU1_PWR_IN_ALERT_N", "FM_PVCCIN_CPU2_PWR_IN_ALERT_N", + "IRQ_PVCCIN_CPU1_VRHOT_LVC3_N", "IRQ_PVCCIN_CPU2_VRHOT_LVC3_N", + "FM_CPU1_PROCHOT_BMC_LVC3_N", "", + "FM_CPU1_MEMHOT_OUT_N", "FM_CPU2_MEMHOT_OUT_N", + /* N */ "", "", "", "", "", "", "", "", + /* O */ "", "", "", "", "", "", "", "", + /* P */ "", "", "", "", "", "", "", "", + /* Q */ "", "", "", "", "", "", "RST_GLB_RST_WARN_N", "PCIE_WAKE_N", + /* R */ "", "", "FM_BMC_SUSACK_N", "FM_BMC_EUP_LOT6_N", + "", "FM_BMC_PCH_SCI_LPC_N", "", "", + /* S */ "FM_DBP_PRESENT_N", "FM_CPU2_SKTOCC_LCT3_N", + "FM_CPU1_FIVR_FAULT_LVT3", "FM_CPU2_FIVR_FAULT_LVT3", + "", "", "", "", + /* T */ "", "", "", "", "", "", "", "", + /* U */ "", "", "", "", "", "", "", "", + /* V */ "", "", "", "", "", "", "", "", + /* W */ "", "", "", "", "", "", "", "", + /* X */ "", "", "", "", "", "", "", "", + /* Y */ "FM_SLPS3_N", "FM_SLPS4_N", "", "FM_BMC_ONCTL_N_PLD", + "", "", "", "", + /* Z */ "FM_CPU_MSMI_CATERR_LVT3_N", "", "SYSTEM_FAULT_LED_N", "BMC_THROTTLE_N", + "", "", "", "", + /* AA */ "FM_CPU1_THERMTRIP_LATCH_LVT3_N", "FM_CPU2_THERMTRIP_LATCH_LVT3_N", + "FM_BIOS_POST_COMPLT_N", "DBP_BMC_SYSPWROK", + "", "IRQ_SML0_ALERT_MUX_N", + "IRQ_SMI_ACTIVE_N", "IRQ_NMI_EVENT_N", + /* AB */ "FM_PCH_BMC_THERMTRIP_N", "PWRGD_SYS_PWROK", + "ME_OVERRIDE", "IRQ_BMC_PCH_SMI_LPC_N", + "", "", "", "", + /* AC */ "", "", "", "", "", "", "", ""; +}; + +&adc { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc0_default /* 3VSB */ + &pinctrl_adc1_default /* 5VSB */ + &pinctrl_adc2_default /* CPU1 */ + &pinctrl_adc3_default /* NC */ + &pinctrl_adc4_default /* VCCMABCD */ + &pinctrl_adc5_default /* VCCMEFGH */ + &pinctrl_adc6_default /* NC */ + &pinctrl_adc7_default /* NC */ + &pinctrl_adc8_default /* PVNN_PCH */ + &pinctrl_adc9_default /* 1P05PCH */ + &pinctrl_adc10_default /* 1P8PCH */ + &pinctrl_adc11_default /* BAT */ + &pinctrl_adc12_default /* 3V */ + &pinctrl_adc13_default /* 5V */ + &pinctrl_adc14_default /* 12V */ + &pinctrl_adc15_default>; /* GND */ +}; -- 2.43.0 From zev at bewilderbeest.net Wed Dec 6 13:37:39 2023 From: zev at bewilderbeest.net (Zev Weiss) Date: Tue, 5 Dec 2023 18:37:39 -0800 Subject: [PATCH linux dev-6.5 3/4] dt-bindings: arm: aspeed: document ASRock E3C256D4I In-Reply-To: <20231206023742.5242-6-zev@bewilderbeest.net> References: <20231206023742.5242-6-zev@bewilderbeest.net> Message-ID: <20231206023742.5242-9-zev@bewilderbeest.net> Document ASRock E3C256D4I board compatible. Signed-off-by: Zev Weiss Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20231114112722.28506-5-zev at bewilderbeest.net Signed-off-by: Joel Stanley (cherry picked from commit 87ac7669fbb307682cca553bb78c28ff942fddb4) --- Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml b/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml index 00a673c7bd9e..1f65e8a245b2 100644 --- a/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml +++ b/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml @@ -35,6 +35,7 @@ properties: - ampere,mtjade-bmc - aspeed,ast2500-evb - asrock,e3c246d4i-bmc + - asrock,e3c256d4i-bmc - asrock,romed8hm3-bmc - asrock,spc621d8hm3-bmc - bytedance,g220a-bmc -- 2.43.0 From zev at bewilderbeest.net Wed Dec 6 13:37:37 2023 From: zev at bewilderbeest.net (Zev Weiss) Date: Tue, 5 Dec 2023 18:37:37 -0800 Subject: [PATCH linux dev-6.5 1/4] dt-bindings: arm: aspeed: document ASRock SPC621D8HM3 In-Reply-To: <20231206023742.5242-6-zev@bewilderbeest.net> References: <20231206023742.5242-6-zev@bewilderbeest.net> Message-ID: <20231206023742.5242-7-zev@bewilderbeest.net> Document ASRock SPC621D8HM3 board compatible. Signed-off-by: Zev Weiss Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20231114112819.28572-5-zev at bewilderbeest.net Signed-off-by: Joel Stanley (cherry picked from commit 974277c7fc94443244d1e3d95cdbc54ebaf49fd5) --- Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml b/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml index e17b3d66d6e5..00a673c7bd9e 100644 --- a/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml +++ b/Documentation/devicetree/bindings/arm/aspeed/aspeed.yaml @@ -36,6 +36,7 @@ properties: - aspeed,ast2500-evb - asrock,e3c246d4i-bmc - asrock,romed8hm3-bmc + - asrock,spc621d8hm3-bmc - bytedance,g220a-bmc - facebook,cmm-bmc - facebook,minipack-bmc -- 2.43.0 From joel at jms.id.au Wed Dec 6 17:47:08 2023 From: joel at jms.id.au (Joel Stanley) Date: Wed, 6 Dec 2023 17:17:08 +1030 Subject: [PATCH linux dev-6.5 0/4] Add device trees for ASrock E3C256D4I & SPC621D8HM3 In-Reply-To: <20231206023742.5242-6-zev@bewilderbeest.net> References: <20231206023742.5242-6-zev@bewilderbeest.net> Message-ID: On Wed, 6 Dec 2023 at 13:07, Zev Weiss wrote: > > Hello, > > These patches add support for the BMCs on the ASRock e3c256d4i and > spc621d8hm3 boards. All four patches are currently in the 'for-next' > branch of Joel's bmc.git tree. I used the '-x' flag when > cherry-picking them onto the dev-6.5 branch, but since they're not yet > actually merged into the mainline kernel I suppose it's possible the > upstream commit hashes might still change, so feel free to drop those > tags as preferred. > > [Mistakenly didn't CC the list on first send, apologies for the > duplication Joel & Andrew.] I've merged these on top of the shiny new 6.6 tree. Cheers, Joel From joel at jms.id.au Wed Dec 6 17:59:59 2023 From: joel at jms.id.au (Joel Stanley) Date: Wed, 6 Dec 2023 17:29:59 +1030 Subject: OpenBMC Linux 6.6 Message-ID: Hot on the heels of the last bump, here is the latest kernel base for the aspeed machines. https://gerrit.openbmc.org/c/openbmc/openbmc/+/67772 If you're able to test, please comment on gerrit and give the change a +1. There was a config regression due to CONFIG_EMBEDDED going away, which is fixed separately here: https://gerrit.openbmc.org/c/openbmc/openbmc/+/68117 Commit message for the bump follows: There are 56 patches in the tree, with 36 of those patches not yet queued for merging in v6.7. v6.6 is an LTS kernel as decreed by the kernel.org maintainers. The OpenBMC kernel maintainers encourage everyone to ship the latest kernel as it has the most code review and upstream code. Andrew Jeffery (6): dt-bindings: hwmon: pmbus: Add Maxim MAX31785 documentation pmbus (max31785): Add support for devicetree configuration pmbus (core): One-shot retries for failure to set page pmbus (max31785): Wrap all I2C accessors in one-shot failure handlers ARM: dts: aspeed: witherspoon: Update max31785 node ipmi: kcs_bmc: Add a "raw" character device interface C?dric Le Goater (1): /dev/mem: add a devmem kernel parameter to activate the device Eddie James (19): dt-bindings: soc: Add Aspeed XDMA Engine soc: aspeed: Add XDMA Engine Driver soc: aspeed: xdma: Add user interface soc: aspeed: xdma: Add reset ioctl soc: aspeed: xdma: Add trace events i2c: core: Add mux root adapter operations iio: si7020: Lock root adapter to wait for reset eeprom: ee1004: Enable devices on multiple busses dt-bindings: trivial-devices: Add Atmel AT30TSE004A serial eeprom eeprom: ee1004: Add OF matching support leds: pca955x: Refactor with helper functions and renaming leds: pca955x: Use pointers to driver data rather than I2C client leds: pca955x: Optimize probe led selection leds: pca955x: Add HW blink support leds: Ensure hardware blinking turns off when requested ARM: dts: aspeed: Rainier: Add fan controller properties ARM: dts: aspeed: Everest: Add fan controller properties ARM: dts: aspeed: Bonnell: Add fan controller properties ARM: dts: aspeed: Rainier 4U: Delete fan dual-tach properties Jae Hyun Yoo (1): clk: ast2600: enable BCLK for PCI/PCIe bus always Joel Stanley (7): net: ftgmac100: Ensure tx descriptor updates are visible ARM: aspeed: Add debugfs directory ARM: soc: aspeed: Add secure boot controller support dt-bindings: trivial-devices: Remove Infineon SLB9673 TPM ARM: dts: nuvoton: npmc750-evb: Add default console tpm: tis-i2c: Add more compatible strings leds: pca955x: Revert "Remove the unused function pca95xx_num_led_regs()" Johannes Holland (1): dt-bindings: tpm: Add schema for TIS I2C devices Potin Lai (1): mtd: spi-nor: winbond: Add support for w25q01jvq Change-Id: I8b756421a7da84c0070e2ad4ac84a93984703457 Signed-off-by: Joel Stanley From tmaimon77 at gmail.com Wed Dec 6 18:43:23 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 6 Dec 2023 09:43:23 +0200 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: Hi Joel, Thanks for supporting kernel 6.6 Could you add the following NPCM drivers to kernel 6.6. support Nuvoton NPCM Video Capture/Encode Engine Add Nuvoton NPCM SGPIO feature MMC: add NPCM SDHCI driver support hwmon: npcm: add Arbel NPCM8XX support usb: ChipIdea: add Nuvoton NPCM UDC support On Wed, 6 Dec 2023 at 09:01, Joel Stanley wrote: > > Hot on the heels of the last bump, here is the latest kernel base for > the aspeed machines. > > https://gerrit.openbmc.org/c/openbmc/openbmc/+/67772 > > If you're able to test, please comment on gerrit and give the change a +1. > > There was a config regression due to CONFIG_EMBEDDED going away, which > is fixed separately here: > > https://gerrit.openbmc.org/c/openbmc/openbmc/+/68117 > > Commit message for the bump follows: > > There are 56 patches in the tree, with 36 of those patches not > yet queued for merging in v6.7. > > v6.6 is an LTS kernel as decreed by the kernel.org maintainers. The > OpenBMC kernel maintainers encourage everyone to ship the latest kernel > as it has the most code review and upstream code. > > Andrew Jeffery (6): > dt-bindings: hwmon: pmbus: Add Maxim MAX31785 documentation > pmbus (max31785): Add support for devicetree configuration > pmbus (core): One-shot retries for failure to set page > pmbus (max31785): Wrap all I2C accessors in one-shot failure handlers > ARM: dts: aspeed: witherspoon: Update max31785 node > ipmi: kcs_bmc: Add a "raw" character device interface > > C?dric Le Goater (1): > /dev/mem: add a devmem kernel parameter to activate the device > > Eddie James (19): > dt-bindings: soc: Add Aspeed XDMA Engine > soc: aspeed: Add XDMA Engine Driver > soc: aspeed: xdma: Add user interface > soc: aspeed: xdma: Add reset ioctl > soc: aspeed: xdma: Add trace events > i2c: core: Add mux root adapter operations > iio: si7020: Lock root adapter to wait for reset > eeprom: ee1004: Enable devices on multiple busses > dt-bindings: trivial-devices: Add Atmel AT30TSE004A serial eeprom > eeprom: ee1004: Add OF matching support > leds: pca955x: Refactor with helper functions and renaming > leds: pca955x: Use pointers to driver data rather than I2C client > leds: pca955x: Optimize probe led selection > leds: pca955x: Add HW blink support > leds: Ensure hardware blinking turns off when requested > ARM: dts: aspeed: Rainier: Add fan controller properties > ARM: dts: aspeed: Everest: Add fan controller properties > ARM: dts: aspeed: Bonnell: Add fan controller properties > ARM: dts: aspeed: Rainier 4U: Delete fan dual-tach properties > > Jae Hyun Yoo (1): > clk: ast2600: enable BCLK for PCI/PCIe bus always > > Joel Stanley (7): > net: ftgmac100: Ensure tx descriptor updates are visible > ARM: aspeed: Add debugfs directory > ARM: soc: aspeed: Add secure boot controller support > dt-bindings: trivial-devices: Remove Infineon SLB9673 TPM > ARM: dts: nuvoton: npmc750-evb: Add default console > tpm: tis-i2c: Add more compatible strings > leds: pca955x: Revert "Remove the unused function pca95xx_num_led_regs()" > > Johannes Holland (1): > dt-bindings: tpm: Add schema for TIS I2C devices > > Potin Lai (1): > mtd: spi-nor: winbond: Add support for w25q01jvq > > Change-Id: I8b756421a7da84c0070e2ad4ac84a93984703457 > Signed-off-by: Joel Stanley Thanks, Tomer From joel at jms.id.au Wed Dec 6 18:46:45 2023 From: joel at jms.id.au (Joel Stanley) Date: Wed, 6 Dec 2023 18:16:45 +1030 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: On Wed, 6 Dec 2023 at 18:13, Tomer Maimon wrote: > > Hi Joel, > > Thanks for supporting kernel 6.6 > > Could you add the following NPCM drivers to kernel 6.6. > support Nuvoton NPCM Video Capture/Encode Engine > Add Nuvoton NPCM SGPIO feature > MMC: add NPCM SDHCI driver support > hwmon: npcm: add Arbel NPCM8XX support > usb: ChipIdea: add Nuvoton NPCM UDC support If you can send SHAs for the upstream commits, we can cherry pick them. If they're not upstream, but someone is actively working on them, then please post the lore links and we can look at them. Cheers, Joel From tmaimon77 at gmail.com Wed Dec 6 18:54:21 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 6 Dec 2023 09:54:21 +0200 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: Will send SHAs of upstream drivers in kernel 6.7 Thanks, Tomer On Wed, 6 Dec 2023 at 09:46, Joel Stanley wrote: > > On Wed, 6 Dec 2023 at 18:13, Tomer Maimon wrote: > > > > Hi Joel, > > > > Thanks for supporting kernel 6.6 > > > > Could you add the following NPCM drivers to kernel 6.6. > > support Nuvoton NPCM Video Capture/Encode Engine > > Add Nuvoton NPCM SGPIO feature > > MMC: add NPCM SDHCI driver support > > hwmon: npcm: add Arbel NPCM8XX support > > usb: ChipIdea: add Nuvoton NPCM UDC support > > If you can send SHAs for the upstream commits, we can cherry pick them. > > If they're not upstream, but someone is actively working on them, then > please post the lore links and we can look at them. > > Cheers, > > Joel From tmaimon77 at gmail.com Wed Dec 6 20:07:51 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 6 Dec 2023 11:07:51 +0200 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: Hi Joel The blow patches are upstream to kernel 6.7, only one patch (hwmon: (npcm750-pwm-fan) Add NPCM8xx support) was applied to next Linux version, kernel 6.8) Marvin Lin media: dt-bindings: nuvoton: Add NPCM VCD and ECE engine - f329051273ca01c74a827c70d0d47f2525678b7a dt-bindings: soc: nuvoton: Add NPCM GFXI - c3dea90fdfc16b768add6ef99dfd6eec8a0bf48c media: v4l: Add HEXTILE compressed format - d62d8e7b59f9d7ed9b6eaaa788fee0d727b7d3ad media: v4l2-ctrls: Add user control base for Nuvoton NPCM controls - 2817154cd18942cd89e254d3764a378518a3270f media: uapi: Add controls for NPCM video driver - 1568583b3977f232e6e7a652fd4be95a11d0ecae media: nuvoton: Add driver for NPCM video capture and encoding engine - 46c15a4ff1f4fe078c5b250fb2570020211eab38 Dan Carpenter media: nuvoton: npcm-video: Fix IS_ERR() vs NULL bug - 5f9fcbf92da901495f2f8b09d2f6df5c2ca83dc5 Geert Uytterhoeven media: nuvoton: VIDEO_NPCM_VCD_ECE should depend on ARCH_NPCM - 3e238417254bfdcc23fe207780b59cbb08656762 Tomer Maimon dt-bindings: mmc: npcm,sdhci: Document NPCM SDHCI controller - 4436673a4fe1e83520589f4f05235a510f82f637 mmc: sdhci-npcm: Add NPCM SDHCI driver - 0ebebb21c48408bfa96a6fb18aa1a5bb543e2312 dt-bindings: usb: ci-hdrc-usb2: add npcm750 and npcm845 compatible - ceae398f15b32ebce8db73c15f2603c3b72eca32 usb: chipidea: Add support for NPCM - 70f13579c2f75d869fb989f458fc9937b43c3198 usb: chipidea: add CI_HDRC_FORCE_VBUS_ACTIVE_ALWAYS flag - 2978cc1f285390c1bd4d9bfc665747adc6e4b19c dt-bindings: hwmon: npcm: Add npcm845 compatible string - e56a5e3dfd149573e6134b7eb373d56bc81bd0de hwmon: (npcm750-pwm-fan) Add NPCM8xx support - 0814b07876b4f8752e0d5bd8e15e07426385f35f (found at hwmon-next, https://kernel.googlesource.com/pub/scm/linux/kernel/git/groeck/linux-staging/+/0814b07876b4f8752e0d5bd8e15e07426385f35f) Best regards, Tomer On Wed, 6 Dec 2023 at 09:54, Tomer Maimon wrote: > > Will send SHAs of upstream drivers in kernel 6.7 > > Thanks, > > Tomer > > On Wed, 6 Dec 2023 at 09:46, Joel Stanley wrote: > > > > On Wed, 6 Dec 2023 at 18:13, Tomer Maimon wrote: > > > > > > Hi Joel, > > > > > > Thanks for supporting kernel 6.6 > > > > > > Could you add the following NPCM drivers to kernel 6.6. > > > support Nuvoton NPCM Video Capture/Encode Engine > > > Add Nuvoton NPCM SGPIO feature > > > MMC: add NPCM SDHCI driver support > > > hwmon: npcm: add Arbel NPCM8XX support > > > usb: ChipIdea: add Nuvoton NPCM UDC support > > > > If you can send SHAs for the upstream commits, we can cherry pick them. > > > > If they're not upstream, but someone is actively working on them, then > > please post the lore links and we can look at them. > > > > Cheers, > > > > Joel From chandramohan.harkude at gmail.com Tue Dec 5 19:45:23 2023 From: chandramohan.harkude at gmail.com (Chandramohan) Date: Tue, 5 Dec 2023 14:15:23 +0530 Subject: Suggestions required for sending the RF events in case of change happens on the backend-repos In-Reply-To: References: Message-ID: Dear Patrick Williams and Ed Tanous , I hope this message finds you well. I wanted to bring to your attention some observations regarding the use of Redfish in various repositories in upstream. 1. After going through couple of repositories, I discovered that many upstream repositories are already incorporating Redfish. This is achieved either through journald or by directly calling the phosphor-logging API to log Redfish-specific metadata. The details of this implementation can be found here: link to the implementation . Additionally, this approach is documented in upstream design, available at link to design documentation . 2. As we observe these repositories, it has become apparent that they possess limited knowledge of Redfish, focusing primarily on essential elements like REDFISH_MESSAGE_ID and REDFISH_MESSAGE_ARGS. I would appreciate your insights on whether this approach is considered an anti-pattern or if there are potential drawbacks associated with this minimalistic understanding of Redfish. 1. Currently, our solution is similar; the key distinction lies in our utilization of D-Bus instead of the journal to log Redfish-specific data. 2. Furthermore, we are planning to abstract metadata such as message registry, message arguments and the origin of conditions. This will involve creating a new API that is based on generic (non-Redfish specific) concepts, within Phosphor Logging dedicated to generating logs with Redfish-specific data on the D-Bus. I previously discussed this proposal in more detail in my email from November 2023, which you can find here . Your insights and feedback on this proposal would be greatly appreciated. Best Regards Chandramohan On Fri, Dec 1, 2023 at 11:54?PM Patrick Williams wrote: > On Wed, Nov 29, 2023 at 11:33:30PM +0530, Chandramohan wrote: > > H All, > > > > I wanted to discuss various design approaches for, sending RF events from > > various OpenBMC services for resource create/delete/modify cases (but not > > limited to this), > > Please find the details below: > > I'm not fully grasping what you're trying to solve. Do you have more > details on what your use-case is? > > Generally we _don't_ want all the repositories to know "Redfish". If > what you're proposing is some special Redfish-oriented handling in every > repository, I don't think this will fly. > > For Redfish Events, I suspect someone would need to start a dbus monitor > in BMC web to observe interesting changes and to turn them into Redfish > Events inside bmcweb itself. > > -- > Patrick Williams > -------------- next part -------------- An HTML attachment was scrubbed... URL: From maxime.chevallier at bootlin.com Tue Dec 5 23:32:05 2023 From: maxime.chevallier at bootlin.com (Maxime Chevallier) Date: Tue, 5 Dec 2023 13:32:05 +0100 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: <20231205103559.9605-10-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> Message-ID: <20231205133205.3309ab91@device.home> Hi Serge, On Tue, 5 Dec 2023 13:35:30 +0300 Serge Semin wrote: > Synopsys DesignWare XPCS IP-core can be synthesized with the device CSRs > being accessible over MCI or APB3 interface instead of the MDIO bus (see > the CSR_INTERFACE HDL parameter). Thus all the PCS registers can be just > memory mapped and be a subject of standard MMIO operations of course > taking into account the way the Clause C45 CSRs mapping is defined. This > commit is about adding a device driver for the DW XPCS Management > Interface platform device and registering it in the framework of the > kernel MDIO subsystem. > > DW XPCS platform device is supposed to be described by the respective > compatible string "snps,dw-xpcs-mi", CSRs memory space and optional > peripheral bus clock source. Note depending on the INDIRECT_ACCESS DW XPCS > IP-core synthesize parameter the memory-mapped reg-space can be > represented as either directly or indirectly mapped Clause 45 space. In > the former case the particular address is determined based on the MMD > device and the registers offset (5 + 16 bits all together) within the > device reg-space. In the later case there is only 256 lower address bits > are utilized for the registers mapping. The upper bits are supposed to be > written into the respective viewport CSR in order to reach the entire C45 > space. Too bad the mdio-regmap driver can't be re-used here, it would deal with reg width for you, for example. I guess the main reason would be the direct vs indirect accesses ? I do have a comment tough : [...] > +static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) > +{ > + return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); > +} > + > +static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) > +{ > + return FIELD_GET(0x1fff00, csr); > +} > + > +static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) > +{ > + return FIELD_GET(0xff, csr); > +} You shouldn't use inline in C files, only in headers. Maxime From lkp at intel.com Wed Dec 6 23:28:39 2023 From: lkp at intel.com (kernel test robot) Date: Wed, 6 Dec 2023 20:28:39 +0800 Subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: <20231206014530.1600151-4-jim.t90615@gmail.com> References: <20231206014530.1600151-4-jim.t90615@gmail.com> Message-ID: <202312062043.9nNc7GIZ-lkp@intel.com> Hi Jim, kernel test robot noticed the following build warnings: [auto build test WARNING on brgl/gpio/for-next] [also build test WARNING on robh/for-next linus/master v6.7-rc4 next-20231206] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jim-Liu/dt-bindings-gpio-add-NPCM-sgpio-driver-bindings/20231206-095724 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20231206014530.1600151-4-jim.t90615%40gmail.com patch subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231206/202312062043.9nNc7GIZ-lkp at intel.com/config) compiler: alpha-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312062043.9nNc7GIZ-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312062043.9nNc7GIZ-lkp at intel.com/ All warnings (new ones prefixed by >>): In file included from arch/alpha/include/asm/bug.h:23, from include/linux/bug.h:5, from include/linux/thread_info.h:13, from include/asm-generic/current.h:6, from ./arch/alpha/include/generated/asm/current.h:1, from include/linux/mutex.h:14, from include/linux/notifier.h:14, from include/linux/clk.h:14, from drivers/gpio/gpio-npcm-sgpio.c:9: drivers/gpio/gpio-npcm-sgpio.c: In function 'bank_reg': >> drivers/gpio/gpio-npcm-sgpio.c:150:26: warning: passing argument 1 of 'dev_driver_string' makes pointer from integer without a cast [-Wint-conversion] 150 | dev_WARN(true, "Getting here is an error condition"); | ^~~~ | | | int include/asm-generic/bug.h:99:62: note: in definition of macro '__WARN_printf' 99 | warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ | ^~~ include/linux/dev_printk.h:271:9: note: in expansion of macro 'WARN' 271 | WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg) | ^~~~ drivers/gpio/gpio-npcm-sgpio.c:150:17: note: in expansion of macro 'dev_WARN' 150 | dev_WARN(true, "Getting here is an error condition"); | ^~~~~~~~ In file included from include/linux/platform_device.h:13, from drivers/gpio/gpio-npcm-sgpio.c:16: include/linux/device.h:1242:52: note: expected 'const struct device *' but argument is of type 'int' 1242 | const char *dev_driver_string(const struct device *dev); | ~~~~~~~~~~~~~~~~~~~~~^~~ >> drivers/gpio/gpio-npcm-sgpio.c:150:26: warning: passing argument 1 of 'dev_name' makes pointer from integer without a cast [-Wint-conversion] 150 | dev_WARN(true, "Getting here is an error condition"); | ^~~~ | | | int include/asm-generic/bug.h:99:62: note: in definition of macro '__WARN_printf' 99 | warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ | ^~~ include/linux/dev_printk.h:271:9: note: in expansion of macro 'WARN' 271 | WARN(1, "%s %s: " format, dev_driver_string(dev), dev_name(dev), ## arg) | ^~~~ drivers/gpio/gpio-npcm-sgpio.c:150:17: note: in expansion of macro 'dev_WARN' 150 | dev_WARN(true, "Getting here is an error condition"); | ^~~~~~~~ include/linux/device.h:858:57: note: expected 'const struct device *' but argument is of type 'int' 858 | static inline const char *dev_name(const struct device *dev) | ~~~~~~~~~~~~~~~~~~~~~^~~ drivers/gpio/gpio-npcm-sgpio.c: In function 'npcm_sgpio_dir_out': >> drivers/gpio/gpio-npcm-sgpio.c:211:28: warning: unused variable 'gpio' [-Wunused-variable] 211 | struct npcm_sgpio *gpio = gpiochip_get_data(gc); | ^~~~ drivers/gpio/gpio-npcm-sgpio.c: At top level: >> drivers/gpio/gpio-npcm-sgpio.c:534:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 534 | .sft_clk = npcm750_SFT_CLK, | ^~~~~~~~~~~~~~~ drivers/gpio/gpio-npcm-sgpio.c:535:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 535 | .clk_sel = npcm750_CLK_SEL, | ^~~~~~~~~~~~~~~ drivers/gpio/gpio-npcm-sgpio.c:540:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 540 | .sft_clk = npcm845_SFT_CLK, | ^~~~~~~~~~~~~~~ drivers/gpio/gpio-npcm-sgpio.c:541:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] 541 | .clk_sel = npcm845_CLK_SEL, | ^~~~~~~~~~~~~~~ vim +/dev_driver_string +150 drivers/gpio/gpio-npcm-sgpio.c 134 135 static void __iomem *bank_reg(struct npcm_sgpio *gpio, 136 const struct npcm_sgpio_bank *bank, 137 const enum npcm_sgpio_reg reg) 138 { 139 switch (reg) { 140 case READ_DATA: 141 return gpio->base + bank->rdata_reg; 142 case WRITE_DATA: 143 return gpio->base + bank->wdata_reg; 144 case EVENT_CFG: 145 return gpio->base + bank->event_config; 146 case EVENT_STS: 147 return gpio->base + bank->event_status; 148 default: 149 /* actually if code runs to here, it's an error case */ > 150 dev_WARN(true, "Getting here is an error condition"); 151 } 152 return 0; 153 } 154 155 static const struct npcm_sgpio_bank *offset_to_bank(unsigned int offset) 156 { 157 unsigned int bank = GPIO_BANK(offset); 158 159 return &npcm_sgpio_banks[bank]; 160 } 161 162 static void irqd_to_npcm_sgpio_data(struct irq_data *d, 163 struct npcm_sgpio **gpio, 164 const struct npcm_sgpio_bank **bank, 165 u8 *bit, unsigned int *offset) 166 { 167 struct npcm_sgpio *internal; 168 169 *offset = irqd_to_hwirq(d); 170 internal = irq_data_get_irq_chip_data(d); 171 172 *gpio = internal; 173 *offset -= internal->nout_sgpio; 174 *bank = offset_to_bank(*offset); 175 *bit = GPIO_BIT(*offset); 176 } 177 178 static int npcm_sgpio_init_port(struct npcm_sgpio *gpio) 179 { 180 u8 in_port, out_port, set_port, reg; 181 182 in_port = GPIO_BANK(gpio->nin_sgpio); 183 if (GPIO_BIT(gpio->nin_sgpio) > 0) 184 in_port += 1; 185 186 out_port = GPIO_BANK(gpio->nout_sgpio); 187 if (GPIO_BIT(gpio->nout_sgpio) > 0) 188 out_port += 1; 189 190 gpio->in_port = in_port; 191 gpio->out_port = out_port; 192 set_port = ((out_port & NPCM_IOXCFG2_PORT) << 4) | (in_port & NPCM_IOXCFG2_PORT); 193 iowrite8(set_port, gpio->base + NPCM_IOXCFG2); 194 195 reg = ioread8(gpio->base + NPCM_IOXCFG2); 196 197 return reg == set_port ? 0 : -EINVAL; 198 199 } 200 201 static int npcm_sgpio_dir_in(struct gpio_chip *gc, unsigned int offset) 202 { 203 struct npcm_sgpio *gpio = gpiochip_get_data(gc); 204 205 return offset < gpio->nout_sgpio ? -EINVAL : 0; 206 207 } 208 209 static int npcm_sgpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val) 210 { > 211 struct npcm_sgpio *gpio = gpiochip_get_data(gc); 212 213 gc->set(gc, offset, val); 214 215 return 0; 216 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From fancer.lancer at gmail.com Thu Dec 7 03:48:05 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Wed, 6 Dec 2023 19:48:05 +0300 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: <20231205133205.3309ab91@device.home> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> <20231205133205.3309ab91@device.home> Message-ID: Hi Maxime, On Tue, Dec 05, 2023 at 01:32:05PM +0100, Maxime Chevallier wrote: > Hi Serge, > > On Tue, 5 Dec 2023 13:35:30 +0300 > Serge Semin wrote: > > > Synopsys DesignWare XPCS IP-core can be synthesized with the device CSRs > > being accessible over MCI or APB3 interface instead of the MDIO bus (see > > the CSR_INTERFACE HDL parameter). Thus all the PCS registers can be just > > memory mapped and be a subject of standard MMIO operations of course > > taking into account the way the Clause C45 CSRs mapping is defined. This > > commit is about adding a device driver for the DW XPCS Management > > Interface platform device and registering it in the framework of the > > kernel MDIO subsystem. > > > > DW XPCS platform device is supposed to be described by the respective > > compatible string "snps,dw-xpcs-mi", CSRs memory space and optional > > peripheral bus clock source. Note depending on the INDIRECT_ACCESS DW XPCS > > IP-core synthesize parameter the memory-mapped reg-space can be > > represented as either directly or indirectly mapped Clause 45 space. In > > the former case the particular address is determined based on the MMD > > device and the registers offset (5 + 16 bits all together) within the > > device reg-space. In the later case there is only 256 lower address bits > > are utilized for the registers mapping. The upper bits are supposed to be > > written into the respective viewport CSR in order to reach the entire C45 > > space. > > Too bad the mdio-regmap driver can't be re-used here, it would deal > with reg width for you, for example. I guess the main reason would be > the direct vs indirect accesses ? Right, it's one of the reasons. I could have used the mdio-regmap here, but that would have meant to implement an additional abstraction layer: regspace<->regmap<->mdio-regmap<->mii_bus, instead of just regspace<->mii_bus. This would have also required to patch the mdio-remap module somehow in order to have the c45 ops supported. It would have been much easier to do before the commit 99d5fe9c7f3d ("net: mdio: Remove support for building C45 muxed addresses"). But since then MDIO reg-address has no longer had muxed dev-address. Of course I could have got it back to the mdio-regmap driver only, mix the C22/C45 address in the regmap 'addr' argument, then extract the MMD (for C45) and reg addresses from the regmap IO ops argument and perform the respective MMIO access. But as you can see it is much hardware and would cause additional steps for the address translations, than just directly implement the C22/C45 IO ops and register the MDIO bus for them. I couldn't find much benefits to follow that road, sorry. > > I do have a comment tough : > > [...] > > > +static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) > > +{ > > + return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); > > +} > > + > > +static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) > > +{ > > + return FIELD_GET(0x1fff00, csr); > > +} > > + > > +static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) > > +{ > > + return FIELD_GET(0xff, csr); > > +} > > You shouldn't use inline in C files, only in headers. Could you please clarify why? I failed to find such requirement in the coding style doc. Moreover there are multiple examples of using the static-inline-ers in the C files in the kernel including the net/mdio subsystem. -Serge(y) > > Maxime From andrew at lunn.ch Thu Dec 7 04:01:30 2023 From: andrew at lunn.ch (Andrew Lunn) Date: Wed, 6 Dec 2023 18:01:30 +0100 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> <20231205133205.3309ab91@device.home> Message-ID: <15e6857a-b1d1-465a-945e-6f31edac62fb@lunn.ch> > > You shouldn't use inline in C files, only in headers. > > Could you please clarify why? I failed to find such requirement in the > coding style doc. Moreover there are multiple examples of using the > static-inline-ers in the C files in the kernel including the net/mdio > subsystem. The compiler does a better job at deciding what to inline than we humans do. If you can show the compiler is doing it wrong, then we might accept them. But in general, netdev does not like inline in .C file. Also, nothing in MDIO is hot path, it spends a lot of time waiting for a slow bus. So inline is likely to just bloat the code for no gain. Andrew From fr0st61te at gmail.com Thu Dec 7 08:23:38 2023 From: fr0st61te at gmail.com (Ivan Mikhaylov) Date: Thu, 07 Dec 2023 00:23:38 +0300 Subject: [PATCH dev-5.6 3/3] net/ncsi: Add NC-SI 1.2 Get MC MAC Address command In-Reply-To: <20231205234843.4013767-3-patrick@stwcx.xyz> References: <20231205234843.4013767-1-patrick@stwcx.xyz> <20231205234843.4013767-3-patrick@stwcx.xyz> Message-ID: <6abc879a2c29cc8b8044c5c483bff5a01750695b.camel@gmail.com> On Tue, 2023-12-05 at 17:48 -0600, Patrick Williams wrote: > From: Peter Delevoryas > > This change adds support for the NC-SI 1.2 Get MC MAC Address > command, > specified here: > > https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.2.0.pdf > > It serves the exact same function as the existing OEM Get MAC Address > commands, so if a channel reports that it supports NC-SI 1.2, we > prefer > to use the standard command rather than the OEM command. > > Verified with an invalid MAC address and 2 valid ones: > > [?? 55.137072] ftgmac100 1e690000.ftgmac eth0: NCSI: Received 3 > provisioned MAC addresses > [?? 55.137614] ftgmac100 1e690000.ftgmac eth0: NCSI: MAC address 0: > 00:00:00:00:00:00 > [?? 55.138026] ftgmac100 1e690000.ftgmac eth0: NCSI: MAC address 1: > fa:ce:b0:0c:20:22 > [?? 55.138528] ftgmac100 1e690000.ftgmac eth0: NCSI: MAC address 2: > fa:ce:b0:0c:20:23 > [?? 55.139241] ftgmac100 1e690000.ftgmac eth0: NCSI: Unable to assign > 00:00:00:00:00:00 to device > [?? 55.140098] ftgmac100 1e690000.ftgmac eth0: NCSI: Set MAC address > to fa:ce:b0:0c:20:22 > > Signed-off-by: Peter Delevoryas > Signed-off-by: Patrick Williams > Signed-off-by: David S. Miller > (cherry picked from commit b8291cf3d1180b5b61299922f17c9441616a805a) > --- > ?net/ncsi/ncsi-cmd.c??? |? 3 ++- > ?net/ncsi/ncsi-manage.c |? 9 +++++++-- > ?net/ncsi/ncsi-pkt.h??? | 10 ++++++++++ > ?net/ncsi/ncsi-rsp.c??? | 41 > ++++++++++++++++++++++++++++++++++++++++- > ?4 files changed, 59 insertions(+), 4 deletions(-) > > diff --git a/net/ncsi/ncsi-cmd.c b/net/ncsi/ncsi-cmd.c > index fd2236ee9a79..b3ff37a181d7 100644 > --- a/net/ncsi/ncsi-cmd.c > +++ b/net/ncsi/ncsi-cmd.c > @@ -270,7 +270,8 @@ static struct ncsi_cmd_handler { > ? { NCSI_PKT_CMD_GPS,??? 0, ncsi_cmd_handler_default }, > ? { NCSI_PKT_CMD_OEM,?? -1, ncsi_cmd_handler_oem???? }, > ? { NCSI_PKT_CMD_PLDM,?? 0, NULL???????????????????? }, > - { NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default } > + { NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default }, > + { NCSI_PKT_CMD_GMCMA,? 0, ncsi_cmd_handler_default } > ?}; > ? > ?static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg > *nca) > diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c > index f3d7fe86fea1..745c788f1d1d 100644 > --- a/net/ncsi/ncsi-manage.c > +++ b/net/ncsi/ncsi-manage.c > @@ -1038,11 +1038,16 @@ static void ncsi_configure_channel(struct > ncsi_dev_priv *ndp) > ? case ncsi_dev_state_config_oem_gma: > ? nd->state = ncsi_dev_state_config_clear_vids; > ? > - nca.type = NCSI_PKT_CMD_OEM; > ? nca.package = np->id; > ? nca.channel = nc->id; > ? ndp->pending_req_num = 1; > - ret = ncsi_gma_handler(&nca, nc->version.mf_id); > + if (nc->version.major >= 1 && nc->version.minor >= > 2) { > + nca.type = NCSI_PKT_CMD_GMCMA; > + ret = ncsi_xmit_cmd(&nca); > + } else { > + nca.type = NCSI_PKT_CMD_OEM; > + ret = ncsi_gma_handler(&nca, nc- > >version.mf_id); > + } > ? if (ret < 0) > ? schedule_work(&ndp->work); > ? > diff --git a/net/ncsi/ncsi-pkt.h b/net/ncsi/ncsi-pkt.h > index c9d1da34dc4d..f2f3b5c1b941 100644 > --- a/net/ncsi/ncsi-pkt.h > +++ b/net/ncsi/ncsi-pkt.h > @@ -338,6 +338,14 @@ struct ncsi_rsp_gpuuid_pkt { > ? __be32????????????????? checksum; > ?}; > ? > +/* Get MC MAC Address */ > +struct ncsi_rsp_gmcma_pkt { > + struct ncsi_rsp_pkt_hdr rsp; > + unsigned char?????????? address_count; > + unsigned char?????????? reserved[3]; > + unsigned char?????????? addresses[][ETH_ALEN]; > +}; > + > ?/* AEN: Link State Change */ > ?struct ncsi_aen_lsc_pkt { > ? struct ncsi_aen_pkt_hdr aen;??????? /* AEN header????? */ > @@ -398,6 +406,7 @@ struct ncsi_aen_hncdsc_pkt { > ?#define NCSI_PKT_CMD_GPUUID 0x52 /* Get package > UUID???????????????? */ > ?#define NCSI_PKT_CMD_QPNPR 0x56 /* Query Pending NC PLDM > request */ > ?#define NCSI_PKT_CMD_SNPR 0x57 /* Send NC PLDM Reply? */ > +#define NCSI_PKT_CMD_GMCMA 0x58 /* Get MC MAC Address */ > ? > ? > ?/* NCSI packet responses */ > @@ -433,6 +442,7 @@ struct ncsi_aen_hncdsc_pkt { > ?#define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80) > ?#define NCSI_PKT_RSP_QPNPR (NCSI_PKT_CMD_QPNPR?? + 0x80) > ?#define NCSI_PKT_RSP_SNPR (NCSI_PKT_CMD_SNPR?? + 0x80) > +#define NCSI_PKT_RSP_GMCMA (NCSI_PKT_CMD_GMCMA? + 0x80) > ? > ?/* NCSI response code/reason */ > ?#define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command > Completed??????? */ > diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c > index 480e80e3c283..bee290d0f48b 100644 > --- a/net/ncsi/ncsi-rsp.c > +++ b/net/ncsi/ncsi-rsp.c > @@ -1091,6 +1091,44 @@ static int ncsi_rsp_handler_netlink(struct > ncsi_request *nr) > ? return ret; > ?} > ? > +static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr) > +{ > + struct ncsi_dev_priv *ndp = nr->ndp; > + struct net_device *ndev = ndp->ndev.dev; > + struct ncsi_rsp_gmcma_pkt *rsp; > + struct sockaddr saddr; > + int ret = -1; > + int i; > + > + rsp = (struct ncsi_rsp_gmcma_pkt *)skb_network_header(nr- > >rsp); > + saddr.sa_family = ndev->type; > + ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; > + > + netdev_info(ndev, "NCSI: Received %d provisioned MAC > addresses\n", > + ??? rsp->address_count); > + for (i = 0; i < rsp->address_count; i++) { > + netdev_info(ndev, "NCSI: MAC address %d: > %02x:%02x:%02x:%02x:%02x:%02x\n", > + ??? i, rsp->addresses[i][0], rsp- > >addresses[i][1], > + ??? rsp->addresses[i][2], rsp- > >addresses[i][3], > + ??? rsp->addresses[i][4], rsp- > >addresses[i][5]); > + } > + > + for (i = 0; i < rsp->address_count; i++) { > + memcpy(saddr.sa_data, &rsp->addresses[i], ETH_ALEN); > + ret = ndev->netdev_ops->ndo_set_mac_address(ndev, > &saddr); > + if (ret < 0) { > + netdev_warn(ndev, "NCSI: Unable to assign > %pM to device\n", > + ??? saddr.sa_data); > + continue; > + } > + netdev_warn(ndev, "NCSI: Set MAC address to %pM\n", > saddr.sa_data); > + break; > + } > + > + ndp->gma_flag = ret == 0; > + return ret; > +} > + > ?static struct ncsi_rsp_handler { > ? unsigned char type; > ? int???????????? payload; > @@ -1127,7 +1165,8 @@ static struct ncsi_rsp_handler { > ? { NCSI_PKT_RSP_PLDM,?? -1, ncsi_rsp_handler_pldm??? }, > ? { NCSI_PKT_RSP_GPUUID, 20, ncsi_rsp_handler_gpuuid? }, > ? { NCSI_PKT_RSP_QPNPR,? -1, ncsi_rsp_handler_pldm??? }, > - { NCSI_PKT_RSP_SNPR,?? -1, ncsi_rsp_handler_pldm??? } > + { NCSI_PKT_RSP_SNPR,?? -1, ncsi_rsp_handler_pldm??? }, > + { NCSI_PKT_RSP_GMCMA,? -1, ncsi_rsp_handler_gmcma?? }, > ?}; > ? > ?int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev, Patrick, I've the fix about ndo_set_mac_address not so long in the past https://lore.kernel.org/all/20230828101151.684010399 at linuxfoundation.org/ ndo_set_mac_address do not notify network layer about mac change. Thanks. From joel at jms.id.au Thu Dec 7 11:14:39 2023 From: joel at jms.id.au (Joel Stanley) Date: Thu, 7 Dec 2023 10:44:39 +1030 Subject: [PATCH linux dev-6.5 0/2] hwmon: (pmbus) MPS mp5990 hsc controller In-Reply-To: <20231122063228.4037027-1-potin.lai@quantatw.com> References: <20231122063228.4037027-1-potin.lai@quantatw.com> Message-ID: On Wed, 22 Nov 2023 at 17:04, Potin Lai wrote: > > Add MPS mp5990 hot-swap controller. > Link: https://lore.kernel.org/all/20231113155008.2147090-1-peteryin.openbmc at gmail.com/ Merged into dev-6.6. Cheers, Joel From lkp at intel.com Thu Dec 7 11:16:59 2023 From: lkp at intel.com (kernel test robot) Date: Thu, 7 Dec 2023 08:16:59 +0800 Subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: <20231206014530.1600151-4-jim.t90615@gmail.com> References: <20231206014530.1600151-4-jim.t90615@gmail.com> Message-ID: <202312070733.GNrG7abU-lkp@intel.com> Hi Jim, kernel test robot noticed the following build warnings: [auto build test WARNING on brgl/gpio/for-next] [also build test WARNING on robh/for-next linus/master v6.7-rc4 next-20231206] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Jim-Liu/dt-bindings-gpio-add-NPCM-sgpio-driver-bindings/20231206-095724 base: https://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git gpio/for-next patch link: https://lore.kernel.org/r/20231206014530.1600151-4-jim.t90615%40gmail.com patch subject: [PATCH v8 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver config: nios2-randconfig-r131-20231207 (https://download.01.org/0day-ci/archive/20231207/202312070733.GNrG7abU-lkp at intel.com/config) compiler: nios2-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231207/202312070733.GNrG7abU-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312070733.GNrG7abU-lkp at intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct device const *dev @@ got int @@ drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: expected struct device const *dev drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: got int >> drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected struct device const *dev @@ got int @@ drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: expected struct device const *dev drivers/gpio/gpio-npcm-sgpio.c:150:17: sparse: got int >> drivers/gpio/gpio-npcm-sgpio.c:152:16: sparse: sparse: Using plain integer as NULL pointer >> drivers/gpio/gpio-npcm-sgpio.c:534:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *sft_clk @@ got unsigned int const * @@ drivers/gpio/gpio-npcm-sgpio.c:534:20: sparse: expected unsigned int *sft_clk drivers/gpio/gpio-npcm-sgpio.c:534:20: sparse: got unsigned int const * >> drivers/gpio/gpio-npcm-sgpio.c:535:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *clk_sel @@ got unsigned int const * @@ drivers/gpio/gpio-npcm-sgpio.c:535:20: sparse: expected unsigned int *clk_sel drivers/gpio/gpio-npcm-sgpio.c:535:20: sparse: got unsigned int const * drivers/gpio/gpio-npcm-sgpio.c:540:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *sft_clk @@ got unsigned int const * @@ drivers/gpio/gpio-npcm-sgpio.c:540:20: sparse: expected unsigned int *sft_clk drivers/gpio/gpio-npcm-sgpio.c:540:20: sparse: got unsigned int const * drivers/gpio/gpio-npcm-sgpio.c:541:20: sparse: sparse: incorrect type in initializer (different modifiers) @@ expected unsigned int *clk_sel @@ got unsigned int const * @@ drivers/gpio/gpio-npcm-sgpio.c:541:20: sparse: expected unsigned int *clk_sel drivers/gpio/gpio-npcm-sgpio.c:541:20: sparse: got unsigned int const * vim +150 drivers/gpio/gpio-npcm-sgpio.c 134 135 static void __iomem *bank_reg(struct npcm_sgpio *gpio, 136 const struct npcm_sgpio_bank *bank, 137 const enum npcm_sgpio_reg reg) 138 { 139 switch (reg) { 140 case READ_DATA: 141 return gpio->base + bank->rdata_reg; 142 case WRITE_DATA: 143 return gpio->base + bank->wdata_reg; 144 case EVENT_CFG: 145 return gpio->base + bank->event_config; 146 case EVENT_STS: 147 return gpio->base + bank->event_status; 148 default: 149 /* actually if code runs to here, it's an error case */ > 150 dev_WARN(true, "Getting here is an error condition"); 151 } > 152 return 0; 153 } 154 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From joel at jms.id.au Thu Dec 7 14:52:21 2023 From: joel at jms.id.au (Joel Stanley) Date: Thu, 7 Dec 2023 14:22:21 +1030 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: On Wed, 6 Dec 2023 at 19:38, Tomer Maimon wrote: > > Hi Joel > > The blow patches are upstream to kernel 6.7, only one patch (hwmon: > (npcm750-pwm-fan) Add NPCM8xx support) was applied to next Linux > version, kernel 6.8) Nice! The npcm8xxx has been making good progress I see. All of these are merged into the dev-6.6 tree. Cheers, Joel From patrick at stwcx.xyz Thu Dec 7 15:16:25 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Wed, 6 Dec 2023 22:16:25 -0600 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: On Wed, Dec 06, 2023 at 05:29:59PM +1030, Joel Stanley wrote: > Hot on the heels of the last bump, here is the latest kernel base for > the aspeed machines. > > https://gerrit.openbmc.org/c/openbmc/openbmc/+/67772 > > If you're able to test, please comment on gerrit and give the change a +1. What is the tentative timeline for merging this? I'd like to try it out on a few of our platforms but it'll probably be Friday before I get around to that. -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From patrick at stwcx.xyz Thu Dec 7 15:17:58 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Wed, 6 Dec 2023 22:17:58 -0600 Subject: [PATCH dev-5.6 3/3] net/ncsi: Add NC-SI 1.2 Get MC MAC Address command In-Reply-To: <6abc879a2c29cc8b8044c5c483bff5a01750695b.camel@gmail.com> References: <20231205234843.4013767-1-patrick@stwcx.xyz> <20231205234843.4013767-3-patrick@stwcx.xyz> <6abc879a2c29cc8b8044c5c483bff5a01750695b.camel@gmail.com> Message-ID: On Thu, Dec 07, 2023 at 12:23:38AM +0300, Ivan Mikhaylov wrote: > > > Patrick, I've the fix about ndo_set_mac_address not so long in the past > https://lore.kernel.org/all/20230828101151.684010399 at linuxfoundation.org/ > > ndo_set_mac_address do not notify network layer about mac change. Hello Ivan, I think you're suggesting there is a bug in the code that was applied to net-next here? If so, we'll need to get a fix into net-next. These commits are just a backport request to the OpenBMC tree of the code that was already applied to net-next. -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From joel at jms.id.au Thu Dec 7 15:37:33 2023 From: joel at jms.id.au (Joel Stanley) Date: Thu, 7 Dec 2023 15:07:33 +1030 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: On Thu, 7 Dec 2023 at 14:46, Patrick Williams wrote: > > On Wed, Dec 06, 2023 at 05:29:59PM +1030, Joel Stanley wrote: > > Hot on the heels of the last bump, here is the latest kernel base for > > the aspeed machines. > > > > https://gerrit.openbmc.org/c/openbmc/openbmc/+/67772 > > > > If you're able to test, please comment on gerrit and give the change a +1. > > What is the tentative timeline for merging this? I'd like to try it out > on a few of our platforms but it'll probably be Friday before I get > around to that. Once we get a few +1s, in the absence of -1s, it can go in. I can hold off if you want to test your platforms. However, we don't need to hold up for too long. If people find bugs then we can always add fixes on top. Cheers, Joel From dan.carpenter at linaro.org Thu Dec 7 16:41:09 2023 From: dan.carpenter at linaro.org (Dan Carpenter) Date: Thu, 7 Dec 2023 08:41:09 +0300 Subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X In-Reply-To: <20231204055650.788388-3-kcfeng0@nuvoton.com> Message-ID: Hi, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/baneric926-gmail-com/dt-bindings-hwmon-Add-nct736x-bindings/20231204-135942 base: linus/master patch link: https://lore.kernel.org/r/20231204055650.788388-3-kcfeng0%40nuvoton.com patch subject: [PATCH v1 2/2] hwmon: Driver for Nuvoton NCT736X config: m68k-randconfig-r071-20231207 (https://download.01.org/0day-ci/archive/20231207/202312071152.Kfcw1KlD-lkp at intel.com/config) compiler: m68k-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231207/202312071152.Kfcw1KlD-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Reported-by: Dan Carpenter | Closes: https://lore.kernel.org/r/202312071152.Kfcw1KlD-lkp at intel.com/ smatch warnings: drivers/hwmon/nct736x.c:367 nct736x_init_chip() error: uninitialized symbol 'gpio0_3'. drivers/hwmon/nct736x.c:370 nct736x_init_chip() error: uninitialized symbol 'gpio4_7'. drivers/hwmon/nct736x.c:373 nct736x_init_chip() error: uninitialized symbol 'gpio10_13'. drivers/hwmon/nct736x.c:376 nct736x_init_chip() error: uninitialized symbol 'gpio14_17'. vim +/gpio0_3 +367 drivers/hwmon/nct736x.c 16e62bcf3c9b93 Ban Feng 2023-12-04 335 static int nct736x_init_chip(struct i2c_client *client, 16e62bcf3c9b93 Ban Feng 2023-12-04 336 u32 pwm_mask, u32 fanin_mask, u32 wdt_cfg) 16e62bcf3c9b93 Ban Feng 2023-12-04 337 { 16e62bcf3c9b93 Ban Feng 2023-12-04 338 const struct i2c_device_id *id = i2c_match_id(nct736x_id, client); 16e62bcf3c9b93 Ban Feng 2023-12-04 339 u8 i, gpio0_3, gpio4_7, gpio10_13, gpio14_17; 16e62bcf3c9b93 Ban Feng 2023-12-04 340 int ret; 16e62bcf3c9b93 Ban Feng 2023-12-04 341 16e62bcf3c9b93 Ban Feng 2023-12-04 342 for (i = 0; i < NCT736X_PWM_COUNT; i++) { 16e62bcf3c9b93 Ban Feng 2023-12-04 343 if (i < 4) { 16e62bcf3c9b93 Ban Feng 2023-12-04 344 if (pwm_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 345 gpio0_3 |= PWM_SEL(i); This doesn't work. gpio0_3 needs to be initialized to zero before we can turn on individual bits. 16e62bcf3c9b93 Ban Feng 2023-12-04 346 if (fanin_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 347 gpio10_13 |= FANIN_SEL(i); Etc... 16e62bcf3c9b93 Ban Feng 2023-12-04 348 } else if (i < 8) { 16e62bcf3c9b93 Ban Feng 2023-12-04 349 if (pwm_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 350 gpio4_7 |= PWM_SEL(i); 16e62bcf3c9b93 Ban Feng 2023-12-04 351 if (fanin_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 352 gpio14_17 |= FANIN_SEL(i); 16e62bcf3c9b93 Ban Feng 2023-12-04 353 } else if (i < 12) { 16e62bcf3c9b93 Ban Feng 2023-12-04 354 if (pwm_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 355 gpio10_13 |= PWM_SEL(i); 16e62bcf3c9b93 Ban Feng 2023-12-04 356 if (fanin_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 357 gpio0_3 |= FANIN_SEL(i); 16e62bcf3c9b93 Ban Feng 2023-12-04 358 } else { 16e62bcf3c9b93 Ban Feng 2023-12-04 359 if (pwm_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 360 gpio14_17 |= PWM_SEL(i); 16e62bcf3c9b93 Ban Feng 2023-12-04 361 if (fanin_mask & BIT_CHECK(i)) 16e62bcf3c9b93 Ban Feng 2023-12-04 362 gpio4_7 |= FANIN_SEL(i); 16e62bcf3c9b93 Ban Feng 2023-12-04 363 } 16e62bcf3c9b93 Ban Feng 2023-12-04 364 } 16e62bcf3c9b93 Ban Feng 2023-12-04 365 16e62bcf3c9b93 Ban Feng 2023-12-04 366 /* Pin Function Configuration */ 16e62bcf3c9b93 Ban Feng 2023-12-04 @367 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_0_3, gpio0_3); ^^^^^^^ 16e62bcf3c9b93 Ban Feng 2023-12-04 368 if (ret < 0) 16e62bcf3c9b93 Ban Feng 2023-12-04 369 return ret; 16e62bcf3c9b93 Ban Feng 2023-12-04 @370 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_4_7, gpio4_7); 16e62bcf3c9b93 Ban Feng 2023-12-04 371 if (ret < 0) 16e62bcf3c9b93 Ban Feng 2023-12-04 372 return ret; 16e62bcf3c9b93 Ban Feng 2023-12-04 @373 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_10_13, gpio10_13); 16e62bcf3c9b93 Ban Feng 2023-12-04 374 if (ret < 0) 16e62bcf3c9b93 Ban Feng 2023-12-04 375 return ret; 16e62bcf3c9b93 Ban Feng 2023-12-04 @376 ret = nct736x_write_reg(client, NCT736X_REG_GPIO_14_17, gpio14_17); 16e62bcf3c9b93 Ban Feng 2023-12-04 377 if (ret < 0) 16e62bcf3c9b93 Ban Feng 2023-12-04 378 return ret; 16e62bcf3c9b93 Ban Feng 2023-12-04 379 16e62bcf3c9b93 Ban Feng 2023-12-04 380 /* PWM and FANIN Monitoring Enable */ -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From fr0st61te at gmail.com Thu Dec 7 18:44:05 2023 From: fr0st61te at gmail.com (Ivan Mikhaylov) Date: Thu, 07 Dec 2023 10:44:05 +0300 Subject: [PATCH dev-5.6 3/3] net/ncsi: Add NC-SI 1.2 Get MC MAC Address command In-Reply-To: References: <20231205234843.4013767-1-patrick@stwcx.xyz> <20231205234843.4013767-3-patrick@stwcx.xyz> <6abc879a2c29cc8b8044c5c483bff5a01750695b.camel@gmail.com> Message-ID: On Wed, 2023-12-06 at 22:17 -0600, Patrick Williams wrote: > On Thu, Dec 07, 2023 at 12:23:38AM +0300, Ivan Mikhaylov wrote: > > > > > > Patrick, I've the fix about ndo_set_mac_address not so long in the > > past > > https://lore.kernel.org/all/20230828101151.684010399 at linuxfoundation.org/ > > > > ndo_set_mac_address do not notify network layer about mac change. > > Hello Ivan, > > I think you're suggesting there is a bug in the code that was applied > to > net-next here?? If so, we'll need to get a fix into net-next.? These > commits are just a backport request to the OpenBMC tree of the code > that > was already applied to net-next. > Patrick, yes, there is a bug, I'll write to the thread today/tomorrow with that commit about that problem. Need to think how to make a fix for this problem, reverting and make it right until it in net-next or fix above that commit. Thanks. From linus.walleij at linaro.org Thu Dec 7 20:54:58 2023 From: linus.walleij at linaro.org (Linus Walleij) Date: Thu, 7 Dec 2023 10:54:58 +0100 Subject: [PATCH v1 0/5] pinctrl: Use struct pingroup and PINCTRL_PINGROUP() In-Reply-To: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: On Mon, Dec 4, 2023 at 5:00?PM Andy Shevchenko wrote: > This is an excerpt from v4 of the "pinctrl: Convert struct group_desc > to use struct pingroup" [1]. The series has been compiled with GCC 8 > for ARM64 besides x86_64 GCC 13 and LLVM 16. > > Changelog to the mother series [1]: > - added a new patch against Renesas code, so no warnings will be seen Patches applied! Yours, Linus Walleij From patrick at stwcx.xyz Thu Dec 7 23:16:46 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Thu, 7 Dec 2023 06:16:46 -0600 Subject: [PATCH dev-5.6 3/3] net/ncsi: Add NC-SI 1.2 Get MC MAC Address command In-Reply-To: References: <20231205234843.4013767-1-patrick@stwcx.xyz> <20231205234843.4013767-3-patrick@stwcx.xyz> <6abc879a2c29cc8b8044c5c483bff5a01750695b.camel@gmail.com> Message-ID: On Thu, Dec 07, 2023 at 10:44:05AM +0300, Ivan Mikhaylov wrote: > On Wed, 2023-12-06 at 22:17 -0600, Patrick Williams wrote: > > On Thu, Dec 07, 2023 at 12:23:38AM +0300, Ivan Mikhaylov wrote: > > > > > > > > > Patrick, I've the fix about ndo_set_mac_address not so long in the > > > past > > > https://lore.kernel.org/all/20230828101151.684010399 at linuxfoundation.org/ > > > > > > ndo_set_mac_address do not notify network layer about mac change. > > > > Hello Ivan, > > > > I think you're suggesting there is a bug in the code that was applied > > to > > net-next here?? If so, we'll need to get a fix into net-next.? These > > commits are just a backport request to the OpenBMC tree of the code > > that > > was already applied to net-next. > > > > Patrick, yes, there is a bug, I'll write to the thread today/tomorrow > with that commit about that problem. Need to think how to make a fix > for this problem, reverting and make it right until it in net-next or > fix above that commit. Is this the fix? diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c index bee290d0f48b..b02e663e56dc 100644 --- a/net/ncsi/ncsi-rsp.c +++ b/net/ncsi/ncsi-rsp.c @@ -1115,7 +1115,9 @@ static int ncsi_rsp_handler_gmcma(struct ncsi_request *nr) for (i = 0; i < rsp->address_count; i++) { memcpy(saddr.sa_data, &rsp->addresses[i], ETH_ALEN); - ret = ndev->netdev_ops->ndo_set_mac_address(ndev, &saddr); + rtnl_lock(); + ret = dev_set_mac_address(ndev, &saddr, NULL); + rtnl_unlock(); if (ret < 0) { netdev_warn(ndev, "NCSI: Unable to assign %pM to device\n", saddr.sa_data); -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From andriy.shevchenko at linux.intel.com Thu Dec 7 23:37:17 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Thu, 7 Dec 2023 14:37:17 +0200 Subject: [PATCH v1 0/5] pinctrl: Use struct pingroup and PINCTRL_PINGROUP() In-Reply-To: References: <20231204160033.1872569-1-andriy.shevchenko@linux.intel.com> Message-ID: On Thu, Dec 07, 2023 at 10:54:58AM +0100, Linus Walleij wrote: > On Mon, Dec 4, 2023 at 5:00?PM Andy Shevchenko > wrote: > > > This is an excerpt from v4 of the "pinctrl: Convert struct group_desc > > to use struct pingroup" [1]. The series has been compiled with GCC 8 > > for ARM64 besides x86_64 GCC 13 and LLVM 16. > > > > Changelog to the mother series [1]: > > - added a new patch against Renesas code, so no warnings will be seen > > Patches applied! Thank you! I will send the rest after this part appears in Linux Next. -- With Best Regards, Andy Shevchenko From fancer.lancer at gmail.com Fri Dec 8 00:35:47 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 7 Dec 2023 16:35:47 +0300 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: <15e6857a-b1d1-465a-945e-6f31edac62fb@lunn.ch> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> <20231205133205.3309ab91@device.home> <15e6857a-b1d1-465a-945e-6f31edac62fb@lunn.ch> Message-ID: Hi Andrew On Wed, Dec 06, 2023 at 06:01:30PM +0100, Andrew Lunn wrote: > > > You shouldn't use inline in C files, only in headers. > > > > Could you please clarify why? I failed to find such requirement in the > > coding style doc. Moreover there are multiple examples of using the > > static-inline-ers in the C files in the kernel including the net/mdio > > subsystem. > > The compiler does a better job at deciding what to inline than we > humans do. If you can show the compiler is doing it wrong, then we > might accept them. In general I would have agreed with you especially if the methods were heavier than what they are: static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) { return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); } static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) { return FIELD_GET(0x1fff00, csr); } static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) { return FIELD_GET(0xff, csr); } > But in general, netdev does not like inline in .C > file. I see. I'll do as you say if you don't change your mind after my reasoning below. > Also, nothing in MDIO is hot path, it spends a lot of time > waiting for a slow bus. So inline is likely to just bloat the code for > no gain. I would have been absolutely with you in this matter, if we were talking about a normal MDIO bus. In this case the devices are accessed over the system IO-memory. So the bus isn't that slow. Regarding the compiler knowing better when to inline the code. Here is what it does with the methods above. If the inline keyword is specified the compiler will inline all three methods. If the keyword isn't specified then dw_xpcs_mmio_addr_format() won't be inlined while the rest two functions will be. So the only part at consideration is the dw_xpcs_mmio_addr_format() method since the rest of the functions are inlined anyway. The dw_xpcs_mmio_addr_format() function body is of the 5 asm instructions length (on MIPS). Since the function call in this case requires two jump instructions (to function and back), one instruction to save the previous return address on stack and two instructions for the function arguments, the trade-off of having non-inlined function are those five additional instructions on each call. There are four dw_xpcs_mmio_addr_format() calls. So here is what we get in both cases: inlined: 5 func ins * 4 calls = 20 ins non-inlined: (5 func + 1 jump) ins + (1 jump + 1 ra + 2 arg) ins * 4 calls = 22 ins but seeing the return address needs to be saved anyway in the callers here is what we finally get: non-inlined: (5 func + 1 jump) ins + (1 jump + 2 arg) ins * 4 calls = 18 ins So unless I am mistaken in some of the aspects if we have the function non-inlined then we'll save 2 instructions in the object file, but each call would require additional _4_ instructions to execute (2 jumps and 2 arg creations), which makes the function execution almost two times longer than it would have been should it was inlined. IMO in this case saving 2 instructions of the object file isn't worth than getting rid from four instructions on each call seeing the DW XPCS MCI/APB3 buses are the memory IO interfaces which don't require any long-time waits to perform the ops. Thus I'd suggest to keep the inline keywords specified here. What is your conclusion? -Serge(y) > > Andrew From linux at armlinux.org.uk Fri Dec 8 01:02:27 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Thu, 7 Dec 2023 14:02:27 +0000 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> <20231205133205.3309ab91@device.home> <15e6857a-b1d1-465a-945e-6f31edac62fb@lunn.ch> Message-ID: On Thu, Dec 07, 2023 at 04:35:47PM +0300, Serge Semin wrote: > Hi Andrew > > On Wed, Dec 06, 2023 at 06:01:30PM +0100, Andrew Lunn wrote: > > The compiler does a better job at deciding what to inline than we > > humans do. If you can show the compiler is doing it wrong, then we > > might accept them. > > In general I would have agreed with you especially if the methods were > heavier than what they are: > static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) > { > return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); > } > > static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) > { > return FIELD_GET(0x1fff00, csr); > } > > static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) > { > return FIELD_GET(0xff, csr); > } > > > But in general, netdev does not like inline in .C > > file. > > I see. I'll do as you say if you don't change your mind after my > reasoning below. This isn't Andrew saying it - you seem to have missed the detail that "netdev". If Andrew doesn't say it, then DaveM, Jakub or Paolo will. Have you read the "Inline functions" section in Documentation/process/4.Coding.rst ? > > Also, nothing in MDIO is hot path, it spends a lot of time > > waiting for a slow bus. So inline is likely to just bloat the code for > > no gain. > > I would have been absolutely with you in this matter, if we were talking > about a normal MDIO bus. In this case the devices are accessed over > the system IO-memory. So the bus isn't that slow. > > Regarding the compiler knowing better when to inline the code. Here is > what it does with the methods above. If the inline keyword is > specified the compiler will inline all three methods. If the keyword isn't > specified then dw_xpcs_mmio_addr_format() won't be inlined while the rest > two functions will be. So the only part at consideration is the > dw_xpcs_mmio_addr_format() method since the rest of the functions are > inlined anyway. > > The dw_xpcs_mmio_addr_format() function body is of the 5 asm > instructions length (on MIPS). Since the function call in this case > requires two jump instructions (to function and back), one instruction > to save the previous return address on stack and two instructions for > the function arguments, the trade-off of having non-inlined function > are those five additional instructions on each call. There are four > dw_xpcs_mmio_addr_format() calls. So here is what we get in both > cases: > inlined: 5 func ins * 4 calls = 20 ins > non-inlined: (5 func + 1 jump) ins + (1 jump + 1 ra + 2 arg) ins * 4 calls = 22 ins > but seeing the return address needs to be saved anyway in the callers > here is what we finally get: > non-inlined: (5 func + 1 jump) ins + (1 jump + 2 arg) ins * 4 calls = 18 ins > > So unless I am mistaken in some of the aspects if we have the function > non-inlined then we'll save 2 instructions in the object file, but > each call would require additional _4_ instructions to execute (2 > jumps and 2 arg creations), which makes the function execution almost > two times longer than it would have been should it was inlined. Rather than just focusing on instruction count, you also need to consider things like branch prediction, prefetching and I-cache usage. Modern CPUs don't execute instruction-by-instruction anymore. It is entirely possible that the compiler is making better choices even if it results in more jumps in the code. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From fancer.lancer at gmail.com Fri Dec 8 01:37:03 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 7 Dec 2023 17:37:03 +0300 Subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" In-Reply-To: <202312060634.Cblfigt2-lkp@intel.com> References: <20231205103559.9605-12-fancer.lancer@gmail.com> <202312060634.Cblfigt2-lkp@intel.com> Message-ID: On Wed, Dec 06, 2023 at 07:03:46AM +0800, kernel test robot wrote: > Hi Serge, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on net-next/main] > > url: https://github.com/intel-lab-lkp/linux/commits/Serge-Semin/net-pcs-xpcs-Drop-sentinel-entry-from-2500basex-ifaces-list/20231205-183808 > base: net-next/main > patch link: https://lore.kernel.org/r/20231205103559.9605-12-fancer.lancer%40gmail.com > patch subject: [PATCH net-next 11/16] net: pcs: xpcs: Change xpcs_create_mdiodev() suffix to "byaddr" > config: arc-randconfig-001-20231206 (https://download.01.org/0day-ci/archive/20231206/202312060634.Cblfigt2-lkp at intel.com/config) > compiler: arc-elf-gcc (GCC) 13.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060634.Cblfigt2-lkp at intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot > | Closes: https://lore.kernel.org/oe-kbuild-all/202312060634.Cblfigt2-lkp at intel.com/ > > All error/warnings (new ones prefixed by >>): > > drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c: In function 'txgbe_mdio_pcs_init': > >> drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:150:16: error: implicit declaration of function 'xpcs_create_mdiodev'; did you mean 'xpcs_create_byaddr'? [-Werror=implicit-function-declaration] > 150 | xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); > | ^~~~~~~~~~~~~~~~~~~ > | xpcs_create_byaddr > >> drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:150:14: warning: assignment to 'struct dw_xpcs *' from 'int' makes pointer from integer without a cast [-Wint-conversion] > 150 | xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); > | ^ > cc1: some warnings being treated as errors > > > vim +150 drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c Ah, right. I had been creating the series some times earlier than this code was introduced and just missed it on the last rebase. I'll fix this on v2. -Serge(y) > > 854cace61387b6 Jiawen Wu 2023-06-06 121 > 854cace61387b6 Jiawen Wu 2023-06-06 122 static int txgbe_mdio_pcs_init(struct txgbe *txgbe) > 854cace61387b6 Jiawen Wu 2023-06-06 123 { > 854cace61387b6 Jiawen Wu 2023-06-06 124 struct mii_bus *mii_bus; > 854cace61387b6 Jiawen Wu 2023-06-06 125 struct dw_xpcs *xpcs; > 854cace61387b6 Jiawen Wu 2023-06-06 126 struct pci_dev *pdev; > 854cace61387b6 Jiawen Wu 2023-06-06 127 struct wx *wx; > 854cace61387b6 Jiawen Wu 2023-06-06 128 int ret = 0; > 854cace61387b6 Jiawen Wu 2023-06-06 129 > 854cace61387b6 Jiawen Wu 2023-06-06 130 wx = txgbe->wx; > 854cace61387b6 Jiawen Wu 2023-06-06 131 pdev = wx->pdev; > 854cace61387b6 Jiawen Wu 2023-06-06 132 > 854cace61387b6 Jiawen Wu 2023-06-06 133 mii_bus = devm_mdiobus_alloc(&pdev->dev); > 854cace61387b6 Jiawen Wu 2023-06-06 134 if (!mii_bus) > 854cace61387b6 Jiawen Wu 2023-06-06 135 return -ENOMEM; > 854cace61387b6 Jiawen Wu 2023-06-06 136 > 854cace61387b6 Jiawen Wu 2023-06-06 137 mii_bus->name = "txgbe_pcs_mdio_bus"; > 854cace61387b6 Jiawen Wu 2023-06-06 138 mii_bus->read_c45 = &txgbe_pcs_read; > 854cace61387b6 Jiawen Wu 2023-06-06 139 mii_bus->write_c45 = &txgbe_pcs_write; > 854cace61387b6 Jiawen Wu 2023-06-06 140 mii_bus->parent = &pdev->dev; > 854cace61387b6 Jiawen Wu 2023-06-06 141 mii_bus->phy_mask = ~0; > 854cace61387b6 Jiawen Wu 2023-06-06 142 mii_bus->priv = wx; > 854cace61387b6 Jiawen Wu 2023-06-06 143 snprintf(mii_bus->id, MII_BUS_ID_SIZE, "txgbe_pcs-%x", > d8c21ef7b2b147 Xiongfeng Wang 2023-08-08 144 pci_dev_id(pdev)); > 854cace61387b6 Jiawen Wu 2023-06-06 145 > 854cace61387b6 Jiawen Wu 2023-06-06 146 ret = devm_mdiobus_register(&pdev->dev, mii_bus); > 854cace61387b6 Jiawen Wu 2023-06-06 147 if (ret) > 854cace61387b6 Jiawen Wu 2023-06-06 148 return ret; > 854cace61387b6 Jiawen Wu 2023-06-06 149 > 854cace61387b6 Jiawen Wu 2023-06-06 @150 xpcs = xpcs_create_mdiodev(mii_bus, 0, PHY_INTERFACE_MODE_10GBASER); > 854cace61387b6 Jiawen Wu 2023-06-06 151 if (IS_ERR(xpcs)) > 854cace61387b6 Jiawen Wu 2023-06-06 152 return PTR_ERR(xpcs); > 854cace61387b6 Jiawen Wu 2023-06-06 153 > 854cace61387b6 Jiawen Wu 2023-06-06 154 txgbe->xpcs = xpcs; > 854cace61387b6 Jiawen Wu 2023-06-06 155 > 854cace61387b6 Jiawen Wu 2023-06-06 156 return 0; > 854cace61387b6 Jiawen Wu 2023-06-06 157 } > 854cace61387b6 Jiawen Wu 2023-06-06 158 > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki From fancer.lancer at gmail.com Fri Dec 8 01:47:11 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 7 Dec 2023 17:47:11 +0300 Subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device In-Reply-To: <202312060845.lDDRDWET-lkp@intel.com> References: <20231205103559.9605-14-fancer.lancer@gmail.com> <202312060845.lDDRDWET-lkp@intel.com> Message-ID: On Wed, Dec 06, 2023 at 08:19:07AM +0800, kernel test robot wrote: > Hi Serge, > > kernel test robot noticed the following build errors: > > [auto build test ERROR on net-next/main] > > url: https://github.com/intel-lab-lkp/linux/commits/Serge-Semin/net-pcs-xpcs-Drop-sentinel-entry-from-2500basex-ifaces-list/20231205-183808 > base: net-next/main > patch link: https://lore.kernel.org/r/20231205103559.9605-14-fancer.lancer%40gmail.com > patch subject: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device > config: x86_64-kexec (https://download.01.org/0day-ci/archive/20231206/202312060845.lDDRDWET-lkp at intel.com/config) > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231206/202312060845.lDDRDWET-lkp at intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot > | Closes: https://lore.kernel.org/oe-kbuild-all/202312060845.lDDRDWET-lkp at intel.com/ > > All errors (new ones prefixed by >>): > > drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c: In function 'intel_mgbe_common_data': > >> drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:646:31: error: 'clk' undeclared (first use in this function) > 646 | clk_disable_unprepare(clk); > | ^~~ > drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c:646:31: note: each undeclared identifier is reported only once for each function it appears in > > > vim +/clk +646 drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c Right, my series had been originally based on a branch which had some of this driver parts fixed. I should have more thoroughly performed the re-base process. I'll make sure it's fixed on v2. -Serge(y) > > 446 > 447 static int intel_mgbe_common_data(struct pci_dev *pdev, > 448 struct plat_stmmacenet_data *plat) > 449 { > 450 struct fwnode_handle *fwnode; > 451 char clk_name[20]; > 452 int ret; > 453 int i; > 454 > 455 plat->pdev = pdev; > 456 plat->phy_addr = -1; > 457 plat->clk_csr = 5; > 458 plat->has_gmac = 0; > 459 plat->has_gmac4 = 1; > 460 plat->force_sf_dma_mode = 0; > 461 plat->flags |= (STMMAC_FLAG_TSO_EN | STMMAC_FLAG_SPH_DISABLE); > 462 > 463 /* Multiplying factor to the clk_eee_i clock time > 464 * period to make it closer to 100 ns. This value > 465 * should be programmed such that the clk_eee_time_period * > 466 * (MULT_FACT_100NS + 1) should be within 80 ns to 120 ns > 467 * clk_eee frequency is 19.2Mhz > 468 * clk_eee_time_period is 52ns > 469 * 52ns * (1 + 1) = 104ns > 470 * MULT_FACT_100NS = 1 > 471 */ > 472 plat->mult_fact_100ns = 1; > 473 > 474 plat->rx_sched_algorithm = MTL_RX_ALGORITHM_SP; > 475 > 476 for (i = 0; i < plat->rx_queues_to_use; i++) { > 477 plat->rx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB; > 478 plat->rx_queues_cfg[i].chan = i; > 479 > 480 /* Disable Priority config by default */ > 481 plat->rx_queues_cfg[i].use_prio = false; > 482 > 483 /* Disable RX queues routing by default */ > 484 plat->rx_queues_cfg[i].pkt_route = 0x0; > 485 } > 486 > 487 for (i = 0; i < plat->tx_queues_to_use; i++) { > 488 plat->tx_queues_cfg[i].mode_to_use = MTL_QUEUE_DCB; > 489 > 490 /* Disable Priority config by default */ > 491 plat->tx_queues_cfg[i].use_prio = false; > 492 /* Default TX Q0 to use TSO and rest TXQ for TBS */ > 493 if (i > 0) > 494 plat->tx_queues_cfg[i].tbs_en = 1; > 495 } > 496 > 497 /* FIFO size is 4096 bytes for 1 tx/rx queue */ > 498 plat->tx_fifo_size = plat->tx_queues_to_use * 4096; > 499 plat->rx_fifo_size = plat->rx_queues_to_use * 4096; > 500 > 501 plat->tx_sched_algorithm = MTL_TX_ALGORITHM_WRR; > 502 plat->tx_queues_cfg[0].weight = 0x09; > 503 plat->tx_queues_cfg[1].weight = 0x0A; > 504 plat->tx_queues_cfg[2].weight = 0x0B; > 505 plat->tx_queues_cfg[3].weight = 0x0C; > 506 plat->tx_queues_cfg[4].weight = 0x0D; > 507 plat->tx_queues_cfg[5].weight = 0x0E; > 508 plat->tx_queues_cfg[6].weight = 0x0F; > 509 plat->tx_queues_cfg[7].weight = 0x10; > 510 > 511 plat->dma_cfg->pbl = 32; > 512 plat->dma_cfg->pblx8 = true; > 513 plat->dma_cfg->fixed_burst = 0; > 514 plat->dma_cfg->mixed_burst = 0; > 515 plat->dma_cfg->aal = 0; > 516 plat->dma_cfg->dche = true; > 517 > 518 plat->axi = devm_kzalloc(&pdev->dev, sizeof(*plat->axi), > 519 GFP_KERNEL); > 520 if (!plat->axi) > 521 return -ENOMEM; > 522 > 523 plat->axi->axi_lpi_en = 0; > 524 plat->axi->axi_xit_frm = 0; > 525 plat->axi->axi_wr_osr_lmt = 1; > 526 plat->axi->axi_rd_osr_lmt = 1; > 527 plat->axi->axi_blen[0] = 4; > 528 plat->axi->axi_blen[1] = 8; > 529 plat->axi->axi_blen[2] = 16; > 530 > 531 plat->ptp_max_adj = plat->clk_ptp_rate; > 532 plat->eee_usecs_rate = plat->clk_ptp_rate; > 533 > 534 /* Set system clock */ > 535 sprintf(clk_name, "%s-%s", "stmmac", pci_name(pdev)); > 536 > 537 plat->stmmac_clk = clk_register_fixed_rate(&pdev->dev, > 538 clk_name, NULL, 0, > 539 plat->clk_ptp_rate); > 540 > 541 if (IS_ERR(plat->stmmac_clk)) { > 542 dev_warn(&pdev->dev, "Fail to register stmmac-clk\n"); > 543 plat->stmmac_clk = NULL; > 544 } > 545 > 546 ret = clk_prepare_enable(plat->stmmac_clk); > 547 if (ret) { > 548 clk_unregister_fixed_rate(plat->stmmac_clk); > 549 return ret; > 550 } > 551 > 552 plat->ptp_clk_freq_config = intel_mgbe_ptp_clk_freq_config; > 553 > 554 /* Set default value for multicast hash bins */ > 555 plat->multicast_filter_bins = HASH_TABLE_SIZE; > 556 > 557 /* Set default value for unicast filter entries */ > 558 plat->unicast_filter_entries = 1; > 559 > 560 /* Set the maxmtu to a default of JUMBO_LEN */ > 561 plat->maxmtu = JUMBO_LEN; > 562 > 563 plat->flags |= STMMAC_FLAG_VLAN_FAIL_Q_EN; > 564 > 565 /* Use the last Rx queue */ > 566 plat->vlan_fail_q = plat->rx_queues_to_use - 1; > 567 > 568 /* For fixed-link setup, we allow phy-mode setting */ > 569 fwnode = dev_fwnode(&pdev->dev); > 570 if (fwnode) { > 571 int phy_mode; > 572 > 573 /* "phy-mode" setting is optional. If it is set, > 574 * we allow either sgmii or 1000base-x for now. > 575 */ > 576 phy_mode = fwnode_get_phy_mode(fwnode); > 577 if (phy_mode >= 0) { > 578 if (phy_mode == PHY_INTERFACE_MODE_SGMII || > 579 phy_mode == PHY_INTERFACE_MODE_1000BASEX) > 580 plat->phy_interface = phy_mode; > 581 else > 582 dev_warn(&pdev->dev, "Invalid phy-mode\n"); > 583 } > 584 } > 585 > 586 /* Intel mgbe SGMII interface uses pcs-xcps */ > 587 if (plat->phy_interface == PHY_INTERFACE_MODE_SGMII || > 588 plat->phy_interface == PHY_INTERFACE_MODE_1000BASEX) { > 589 struct mdio_board_info *xpcs_info; > 590 > 591 xpcs_info = devm_kzalloc(&pdev->dev, > 592 sizeof(*xpcs_info) + MII_BUS_ID_SIZE, > 593 GFP_KERNEL); > 594 if (!xpcs_info) { > 595 ret = -ENOMEM; > 596 goto err_alloc_info; > 597 } > 598 > 599 xpcs_info->bus_id = (void *)xpcs_info + sizeof(*xpcs_info); > 600 snprintf((char *)xpcs_info->bus_id, MII_BUS_ID_SIZE, > 601 "stmmac-%x", plat->bus_id); > 602 > 603 snprintf(xpcs_info->modalias, MDIO_NAME_SIZE, "dwxpcs"); > 604 > 605 xpcs_info->mdio_addr = INTEL_MGBE_XPCS_ADDR; > 606 > 607 ret = mdiobus_register_board_info(xpcs_info, 1); > 608 if (ret) > 609 goto err_alloc_info; > 610 > 611 plat->mdio_bus_data->has_xpcs = true; > 612 plat->mdio_bus_data->xpcs_an_inband = true; > 613 } > 614 > 615 /* For fixed-link setup, we clear xpcs_an_inband */ > 616 if (fwnode) { > 617 struct fwnode_handle *fixed_node; > 618 > 619 fixed_node = fwnode_get_named_child_node(fwnode, "fixed-link"); > 620 if (fixed_node) > 621 plat->mdio_bus_data->xpcs_an_inband = false; > 622 > 623 fwnode_handle_put(fixed_node); > 624 } > 625 > 626 /* Ensure mdio bus PHY-scan skips intel serdes and pcs-xpcs */ > 627 plat->mdio_bus_data->phy_mask = 1 << INTEL_MGBE_ADHOC_ADDR; > 628 plat->mdio_bus_data->phy_mask |= 1 << INTEL_MGBE_XPCS_ADDR; > 629 > 630 plat->int_snapshot_num = AUX_SNAPSHOT1; > 631 > 632 plat->crosststamp = intel_crosststamp; > 633 plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN; > 634 > 635 /* Setup MSI vector offset specific to Intel mGbE controller */ > 636 plat->msi_mac_vec = 29; > 637 plat->msi_lpi_vec = 28; > 638 plat->msi_sfty_ce_vec = 27; > 639 plat->msi_sfty_ue_vec = 26; > 640 plat->msi_rx_base_vec = 0; > 641 plat->msi_tx_base_vec = 1; > 642 > 643 return 0; > 644 > 645 err_alloc_info: > > 646 clk_disable_unprepare(clk); > 647 clk_unregister_fixed_rate(clk); > 648 > 649 return ret; > 650 } > 651 > > -- > 0-DAY CI Kernel Test Service > https://github.com/intel/lkp-tests/wiki From andrew at lunn.ch Fri Dec 8 01:54:08 2023 From: andrew at lunn.ch (Andrew Lunn) Date: Thu, 7 Dec 2023 15:54:08 +0100 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> <20231205133205.3309ab91@device.home> <15e6857a-b1d1-465a-945e-6f31edac62fb@lunn.ch> Message-ID: <19ebc244-6d79-4e12-8ac4-fcf046106a07@lunn.ch> On Thu, Dec 07, 2023 at 04:35:47PM +0300, Serge Semin wrote: > Hi Andrew > > On Wed, Dec 06, 2023 at 06:01:30PM +0100, Andrew Lunn wrote: > > > > You shouldn't use inline in C files, only in headers. > > > > > > Could you please clarify why? I failed to find such requirement in the > > > coding style doc. Moreover there are multiple examples of using the > > > static-inline-ers in the C files in the kernel including the net/mdio > > > subsystem. > > > > > The compiler does a better job at deciding what to inline than we > > humans do. If you can show the compiler is doing it wrong, then we > > might accept them. > > In general I would have agreed with you especially if the methods were > heavier than what they are: > static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) > { > return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); > } > > static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) > { > return FIELD_GET(0x1fff00, csr); > } > > static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) > { > return FIELD_GET(0xff, csr); > } > > > But in general, netdev does not like inline in .C > > file. > > I see. I'll do as you say if you don't change your mind after my > reasoning below. > > > Also, nothing in MDIO is hot path, it spends a lot of time > > waiting for a slow bus. So inline is likely to just bloat the code for > > no gain. > > I would have been absolutely with you in this matter, if we were talking > about a normal MDIO bus. In this case the devices are accessed over > the system IO-memory. So the bus isn't that slow. O.K, so its not slow. But how often is it used? PHYs tend to get polled once a second if interrupts are not used. But is the PCS also polled at the same time? Does this optimisation make a noticeable difference at once per second? Do you have a requirement that the system boots very very fast, and this optimisation makes a difference when there is heavier activity on the PCS at boot? Is the saving noticeable, when auto-neg takes a little over 1 second. The best way to make your case is show real world requirements and benchmark results. Andrew From gkeishin at in.ibm.com Fri Dec 8 02:13:35 2023 From: gkeishin at in.ibm.com (GEORGE KEISHING) Date: Thu, 7 Dec 2023 15:13:35 +0000 Subject: OpenBmc Test Repository: Legacy REST support sunset Year end In-Reply-To: References: Message-ID: Greetings, As planned, new branch created https://github.com/openbmc/openbmc-test-automation/tree/v4.0-stable Release Note: https://github.com/openbmc/openbmc-test-automation/releases/tag/v4.0-stable As communicated earlier, the expected changes on latest master will follow starting next year but in phases gracefully. - Remove tools and codes supports which are no longer relevant (refer above release note if you still need it ) - Update/revisit documentation README and other information as part of the activity to maintain the relevant data - Consolidation / Grouping of test suites/files to minimize clutter test directories across the repository - Disable Legacy Rest and default to Redfish ONLY and remove flows which we had to support both in code - Continue to update codes are per new changes in Robot and Python version available. For more information you can reach us out on OpenBMC discord https://discord.gg/8rvZJQbE #test-automation (https://discord.gg/4G3vd5rP ) Regards George Keishing From: GEORGE KEISHING Sent: Friday, September 8, 2023 1:15 PM To: openbmc at lists.ozlabs.org Subject: OpenBmc Test Repository: Legacy REST support sunset Year end Hi All, We are deprecating legacy REST test codes and to discontinue tools used in OpenBMC test this year end. We will branch out as a checkpoint if any users still want to use it in their environment. Post we branch out; we will start scrubbing off test code and some significant changes in the test layout and consolidate overall the test repository. Thank you for your support, feedbacks, and contribution to the test. Regards George Keishing -------------- next part -------------- An HTML attachment was scrubbed... URL: From quan at os.amperecomputing.com Fri Dec 8 14:31:40 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Fri, 8 Dec 2023 10:31:40 +0700 Subject: [PATCH v3 0/2] i2c: aspeed: Late ack Tx done irqs and handle coalesced start with stop conditions Message-ID: <20231208033142.1673232-1-quan@os.amperecomputing.com> This series consists of two patches to handle the below issues observed when testing with slave mode: + The coalesced stop condition with the start conditions + Early ack'ed of Tx done (ACK and NAK) causing "Unexpected Ack on read request". This series was verified with ast2500 and ast2600. The prior discussion could be found at: https://lore.kernel.org/all/20231128075236.2724038-1-quan at os.amperecomputing.com/ v3: + Fix the unconditional write when ack the irqs [Andrew] + Handle the coalesced stop condition with the start conditions [Andrew] + Refactor the code to enhance code readability [Quan] + Revised commit message [Quan] v2: + Split these patches to separate series [Joel] + Added the Fixes lines [Joel] + Fixed multiline comment [Joel] + Refactor irq clearing code [Joel, Guenter] + Revised commit message [Joel, Quan] v1: + These patches are first introduced from this disscusstion https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ Quan Nguyen (2): i2c: aspeed: Handle the coalesced stop conditions with the start conditions. i2c: aspeed: Acknowledge Tx done with and without ACK irq late drivers/i2c/busses/i2c-aspeed.c | 68 +++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 24 deletions(-) -- 2.35.1 From quan at os.amperecomputing.com Fri Dec 8 14:31:41 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Fri, 8 Dec 2023 10:31:41 +0700 Subject: [PATCH v3 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231208033142.1673232-1-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> Message-ID: <20231208033142.1673232-2-quan@os.amperecomputing.com> Some masters may drive the transfers with low enough latency between the nak/stop phase of the current command and the start/address phase of the following command that the interrupts are coalesced by the time we process them. Handle the stop conditions before processing SLAVE_MATCH to fix the complaints that sometimes occur below. "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected 0x00000086, but was 0x00000084" Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") Signed-off-by: Quan Nguyen --- v3: + Change to handle the coalesced stop condition with the start conditions [Andrew] + Revised commit message [Quan] v2: + Split to separate series [Joel] + Added the Fixes line [Joel] + Revised commit message [Quan] v1: + First introduced in https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ --- drivers/i2c/busses/i2c-aspeed.c | 47 ++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 28e2a5fc4528..1c2a4f4c4e1b 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -249,18 +249,45 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) if (!slave) return 0; - command = readl(bus->base + ASPEED_I2C_CMD_REG); + /* + * Handle stop conditions early, prior to SLAVE_MATCH. Some masters may drive + * transfers with low enough latency between the nak/stop phase of the current + * command and the start/address phase of the following command that the + * interrupts are coalesced by the time we process them. + */ + if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { + irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; + bus->slave_state = ASPEED_I2C_SLAVE_STOP; + } - /* Slave was requested, restart state machine. */ + if (irq_status & ASPEED_I2CD_INTR_TX_NAK && + bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; + bus->slave_state = ASPEED_I2C_SLAVE_STOP; + } + + /* Propagate any stop conditions to the slave implementation. */ + if (bus->slave_state == ASPEED_I2C_SLAVE_STOP) { + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); + bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; + } + /* + * Now that we've dealt with any potentially coalesced stop conditions, + * address any start conditions. + */ if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; bus->slave_state = ASPEED_I2C_SLAVE_START; } - /* Slave is not currently active, irq was for someone else. */ + /* + * If the slave has been stopped and not started then slave interrupt + * handling is complete. + */ if (bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) return irq_handled; + command = readl(bus->base + ASPEED_I2C_CMD_REG); dev_dbg(bus->dev, "slave irq status 0x%08x, cmd 0x%08x\n", irq_status, command); @@ -279,17 +306,6 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) irq_handled |= ASPEED_I2CD_INTR_RX_DONE; } - /* Slave was asked to stop. */ - if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { - irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; - bus->slave_state = ASPEED_I2C_SLAVE_STOP; - } - if (irq_status & ASPEED_I2CD_INTR_TX_NAK && - bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { - irq_handled |= ASPEED_I2CD_INTR_TX_NAK; - bus->slave_state = ASPEED_I2C_SLAVE_STOP; - } - switch (bus->slave_state) { case ASPEED_I2C_SLAVE_READ_REQUESTED: if (unlikely(irq_status & ASPEED_I2CD_INTR_TX_ACK)) @@ -324,8 +340,7 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value); break; case ASPEED_I2C_SLAVE_STOP: - i2c_slave_event(slave, I2C_SLAVE_STOP, &value); - bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; + /* Stop event handling is done early. Unreachable. */ break; case ASPEED_I2C_SLAVE_START: /* Slave was just started. Waiting for the next event. */; -- 2.35.1 From quan at os.amperecomputing.com Fri Dec 8 14:31:42 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Fri, 8 Dec 2023 10:31:42 +0700 Subject: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231208033142.1673232-1-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> Message-ID: <20231208033142.1673232-3-quan@os.amperecomputing.com> Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") acknowledges most interrupts early before the slave irq handler is executed, except for the "Receive Done Interrupt status" which is acknowledged late in the interrupt. However, it has been observed that the early acknowledgment of "Transmit Done Interrupt Status" (with ACK or NACK) often causes the interrupt to be raised in READ REQUEST state, that shows the "Unexpected ACK on read request." complaint messages. Assuming that the "Transmit Done" interrupt should only be acknowledged once it is truly processed, this commit fixes that issue by acknowledging interrupts for both ACK and NACK cases late in the interrupt handler. Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") Signed-off-by: Quan Nguyen --- v3: + Fix the unconditinal write when ack the irqs [Andrew] + Refactor the code to enhance code readability [Quan] + Fix grammar in commit message [Quan] v2: + Split to separate series [Joel] + Added the Fixes line [Joel] + Fixed multiline comment [Joel] + Refactor irq clearing code [Joel, Guenter] + Revised commit message [Joel] + Revised commit message [Quan] + About a note to remind why the readl() should immediately follow the writel() to fix the race condition when clearing irq status from commit c926c87b8e36 ("i2c: aspeed: Avoid i2c interrupt status clear race condition"), I think it looks straight forward in this patch and decided not to add that note. [Joel] v1: + First introduced in https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ --- drivers/i2c/busses/i2c-aspeed.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 1c2a4f4c4e1b..967a26dd4ffa 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -617,13 +617,19 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) { struct aspeed_i2c_bus *bus = dev_id; - u32 irq_received, irq_remaining, irq_handled; + u32 irq_received, irq_remaining, irq_handled, irq_ack_last; spin_lock(&bus->lock); irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); - /* Ack all interrupts except for Rx done */ - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, - bus->base + ASPEED_I2C_INTR_STS_REG); + + /* + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would indicate HW to + * start receiving or sending new data, and this may cause a race condition + * as the irq handler has not yet handled these irqs but is being acked. + * Let's ack them late at the end of the irq handler when those are truly processed. + */ + irq_ack_last = ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK; + writel(irq_received & ~irq_ack_last, bus->base + ASPEED_I2C_INTR_STS_REG); readl(bus->base + ASPEED_I2C_INTR_STS_REG); irq_received &= ASPEED_I2CD_INTR_RECV_MASK; irq_remaining = irq_received; @@ -667,12 +673,11 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) "irq handled != irq. expected 0x%08x, but was 0x%08x\n", irq_received, irq_handled); - /* Ack Rx done */ - if (irq_received & ASPEED_I2CD_INTR_RX_DONE) { - writel(ASPEED_I2CD_INTR_RX_DONE, - bus->base + ASPEED_I2C_INTR_STS_REG); + if (irq_received & irq_ack_last) { + writel(irq_received & irq_ack_last, bus->base + ASPEED_I2C_INTR_STS_REG); readl(bus->base + ASPEED_I2C_INTR_STS_REG); } + spin_unlock(&bus->lock); return irq_remaining ? IRQ_NONE : IRQ_HANDLED; } -- 2.35.1 From quan at os.amperecomputing.com Fri Dec 8 14:54:49 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Fri, 8 Dec 2023 10:54:49 +0700 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: <18f842b7-7421-4b47-91dc-643300f81959@os.amperecomputing.com> Hi Joel, We do have some pending patches for upstream, but unfortunately, they have not been merged yet. By the way, I'd like to list them here and hope to get more comments. 1. https://lore.kernel.org/all/20231130072849.3075741-1-quan at os.amperecomputing.com/ There is no feature change on this patch, just a minor change so that, in the case of the bmc ssif message abortion, the annoying printout is limited. 2. https://lore.kernel.org/all/20231208033142.1673232-3-quan at os.amperecomputing.com/ This series is to fix some issues found on the i2c-aspeed driver. This version is new and was posted just after I'm confident with the test results on ast2500 and ast2600. My special thanks to Andrew, whose comment made the code look much better than my original version. 3. https://lore.kernel.org/all/20231130075247.3078931-1-quan at os.amperecomputing.com/ We do see significant improvement with this patch, which is just to simply requeue the mctp packet if, somehow, the i2c core returns with -EAGAIN (arbitration lost). Jeremy has not agreed yet, but I'd like to list it here to see more comments. Thanks a lot in advance. - Quan On 06/12/2023 14:46, Joel Stanley wrote: > On Wed, 6 Dec 2023 at 18:13, Tomer Maimon wrote: >> >> Hi Joel, >> >> Thanks for supporting kernel 6.6 >> >> Could you add the following NPCM drivers to kernel 6.6. >> support Nuvoton NPCM Video Capture/Encode Engine >> Add Nuvoton NPCM SGPIO feature >> MMC: add NPCM SDHCI driver support >> hwmon: npcm: add Arbel NPCM8XX support >> usb: ChipIdea: add Nuvoton NPCM UDC support > > If you can send SHAs for the upstream commits, we can cherry pick them. > > If they're not upstream, but someone is actively working on them, then > please post the lore links and we can look at them. > > Cheers, > > Joel From andrew at codeconstruct.com.au Fri Dec 8 14:56:31 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Fri, 08 Dec 2023 14:26:31 +1030 Subject: [PATCH v3 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231208033142.1673232-2-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-2-quan@os.amperecomputing.com> Message-ID: <79ce9162faeb113ecb13efeb58d95f8a71e1a060.camel@codeconstruct.com.au> On Fri, 2023-12-08 at 10:31 +0700, Quan Nguyen wrote: > Some masters may drive the transfers with low enough latency between > the nak/stop phase of the current command and the start/address phase > of the following command that the interrupts are coalesced by the > time we process them. > Handle the stop conditions before processing SLAVE_MATCH to fix the > complaints that sometimes occur below. > > "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected > 0x00000086, but was 0x00000084" > > Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") > Signed-off-by: Quan Nguyen > --- > v3: > + Change to handle the coalesced stop condition with the start > conditions [Andrew] > + Revised commit message [Quan] > > v2: > + Split to separate series [Joel] > + Added the Fixes line [Joel] > + Revised commit message [Quan] > > v1: > + First introduced in > https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ > --- > drivers/i2c/busses/i2c-aspeed.c | 47 ++++++++++++++++++++++----------- > 1 file changed, 31 insertions(+), 16 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 28e2a5fc4528..1c2a4f4c4e1b 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -249,18 +249,45 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > if (!slave) > return 0; > > - command = readl(bus->base + ASPEED_I2C_CMD_REG); > + /* > + * Handle stop conditions early, prior to SLAVE_MATCH. Some masters may drive > + * transfers with low enough latency between the nak/stop phase of the current > + * command and the start/address phase of the following command that the > + * interrupts are coalesced by the time we process them. > + */ > + if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { > + irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; > + bus->slave_state = ASPEED_I2C_SLAVE_STOP; > + } > > - /* Slave was requested, restart state machine. */ > + if (irq_status & ASPEED_I2CD_INTR_TX_NAK && > + bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { > + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; > + bus->slave_state = ASPEED_I2C_SLAVE_STOP; > + } > + > + /* Propagate any stop conditions to the slave implementation. */ > + if (bus->slave_state == ASPEED_I2C_SLAVE_STOP) { > + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); > + bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; > + } > + /* If there's a reason to do a v4 then an extra empty line above the comment would be nice. But let's not get hung up on that if everyone else is happy. Thanks for the fixes! Reviewed-by: Andrew Jeffery > + * Now that we've dealt with any potentially coalesced stop conditions, > + * address any start conditions. > + */ > if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { > irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; > bus->slave_state = ASPEED_I2C_SLAVE_START; > } > From andrew at codeconstruct.com.au Fri Dec 8 15:00:18 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Fri, 08 Dec 2023 14:30:18 +1030 Subject: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231208033142.1673232-3-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-3-quan@os.amperecomputing.com> Message-ID: On Fri, 2023-12-08 at 10:31 +0700, Quan Nguyen wrote: > Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in > interrupt handler") acknowledges most interrupts early before the slave > irq handler is executed, except for the "Receive Done Interrupt status" > which is acknowledged late in the interrupt. > However, it has been observed that the early acknowledgment of "Transmit > Done Interrupt Status" (with ACK or NACK) often causes the interrupt to > be raised in READ REQUEST state, that shows the > "Unexpected ACK on read request." complaint messages. > > Assuming that the "Transmit Done" interrupt should only be acknowledged > once it is truly processed, this commit fixes that issue by acknowledging > interrupts for both ACK and NACK cases late in the interrupt handler. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > Signed-off-by: Quan Nguyen > --- > v3: > + Fix the unconditinal write when ack the irqs [Andrew] > + Refactor the code to enhance code readability [Quan] > + Fix grammar in commit message [Quan] > > v2: > + Split to separate series [Joel] > + Added the Fixes line [Joel] > + Fixed multiline comment [Joel] > + Refactor irq clearing code [Joel, Guenter] > + Revised commit message [Joel] > + Revised commit message [Quan] > + About a note to remind why the readl() should immediately follow the > writel() to fix the race condition when clearing irq status from commit > c926c87b8e36 ("i2c: aspeed: Avoid i2c interrupt status clear race > condition"), I think it looks straight forward in this patch and decided > not to add that note. [Joel] > > v1: > + First introduced in > https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ > --- > drivers/i2c/busses/i2c-aspeed.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 1c2a4f4c4e1b..967a26dd4ffa 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -617,13 +617,19 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) > { > struct aspeed_i2c_bus *bus = dev_id; > - u32 irq_received, irq_remaining, irq_handled; > + u32 irq_received, irq_remaining, irq_handled, irq_ack_last; `irq_ack_last` might be better as a macro, but you're probably saved by the optimiser anyway. If there's another reason to do a v4 or others are unhappy with it then consider fixing it, otherwise: Reviewed-by: Andrew Jeffery Thanks. From fr0st61te at gmail.com Fri Dec 8 18:25:26 2023 From: fr0st61te at gmail.com (Ivan Mikhaylov) Date: Fri, 08 Dec 2023 10:25:26 +0300 Subject: [PATCH dev-5.6 3/3] net/ncsi: Add NC-SI 1.2 Get MC MAC Address command In-Reply-To: References: <20231205234843.4013767-1-patrick@stwcx.xyz> <20231205234843.4013767-3-patrick@stwcx.xyz> <6abc879a2c29cc8b8044c5c483bff5a01750695b.camel@gmail.com> Message-ID: <5e6b2312d54a2ce030cff6270e2d547a3be93cb5.camel@gmail.com> On Thu, 2023-12-07 at 06:16 -0600, Patrick Williams wrote: > On Thu, Dec 07, 2023 at 10:44:05AM +0300, Ivan Mikhaylov wrote: > > On Wed, 2023-12-06 at 22:17 -0600, Patrick Williams wrote: > > > On Thu, Dec 07, 2023 at 12:23:38AM +0300, Ivan Mikhaylov wrote: > > > > > > > > > > > > Patrick, I've the fix about ndo_set_mac_address not so long in > > > > the > > > > past > > > > https://lore.kernel.org/all/20230828101151.684010399 at linuxfoundation.org/ > > > > > > > > ndo_set_mac_address do not notify network layer about mac > > > > change. > > > > > > Hello Ivan, > > > > > > I think you're suggesting there is a bug in the code that was > > > applied > > > to > > > net-next here?? If so, we'll need to get a fix into net-next.? > > > These > > > commits are just a backport request to the OpenBMC tree of the > > > code > > > that > > > was already applied to net-next. > > > > > > > Patrick, yes, there is a bug, I'll write to the thread > > today/tomorrow > > with that commit about that problem. Need to think how to make a > > fix > > for this problem, reverting and make it right until it in net-next > > or > > fix above that commit. > > Is this the fix? > > diff --git a/net/ncsi/ncsi-rsp.c b/net/ncsi/ncsi-rsp.c > index bee290d0f48b..b02e663e56dc 100644 > --- a/net/ncsi/ncsi-rsp.c > +++ b/net/ncsi/ncsi-rsp.c > @@ -1115,7 +1115,9 @@ static int ncsi_rsp_handler_gmcma(struct > ncsi_request *nr) > ? > ??????? for (i = 0; i < rsp->address_count; i++) { > ??????????????? memcpy(saddr.sa_data, &rsp->addresses[i], ETH_ALEN); > -?????????????? ret = ndev->netdev_ops->ndo_set_mac_address(ndev, > &saddr); > +?????????????? rtnl_lock(); > +?????????????? ret = dev_set_mac_address(ndev, &saddr, NULL); > +?????????????? rtnl_unlock(); > ??????????????? if (ret < 0) { > ??????????????????????? netdev_warn(ndev, "NCSI: Unable to assign %pM > to device\n", > ??????????????????????????????????? saddr.sa_data); > Patrick, yes, this is the fix. Difference in calling of call_netdevice_notifiers from dev_set_mac_address to make sure that everybody aware about mac change which using this interface. Thanks. From fancer.lancer at gmail.com Sat Dec 9 01:11:20 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Fri, 8 Dec 2023 17:11:20 +0300 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: <20231205122316.ihhpklv222f5giz3@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> <20231205122316.ihhpklv222f5giz3@skbuf> Message-ID: Hi Vladimir On Tue, Dec 05, 2023 at 02:23:16PM +0200, Vladimir Oltean wrote: > On Tue, Dec 05, 2023 at 02:35:46PM +0300, Serge Semin wrote: > > Omg, thank you very much for testing the series straight away and > > sorry for the immediate trouble it caused. I'll need some more time > > for investigation. I'll get back to this topic a bit later on this > > week. > > Don't worry, I got suspicious when I was CCed to review only a one-line > change in patch 11/16. It's never about that one line, is it?) Right. I should have added you to the list of recipients of the entire series since the patchset changes more than that. The bug you caught brightly highlights my mistake. I'll make sure you are in the list. I'll add Jiawen and Mengyuan there too since the driver under their maintenance is also affected. Hopefully they'll get to test the series too. > > Anyway, the NULL dev->p is a symptom of device_add() not having been > called, most likely from mdio_device_register(). Absolutely right. I thought that mdio_device_create() having the device_initialize() method called was enough for the device_attach() function being happy. It turns out it wasn't and I missed that the device_private instance is allocated only on the device registration. So I'll need to call mdio_device_register() after all, if I get to preserve the current design of the solution. > > I'll be honest and say that I still don't quite understand what you're > trying to achieve. You're trying to bind the hardcoded mdio_devices > created by xpcs_create() to a driver? My idea was to reuse the mdio_device which has already been created either by means of the MDIO-bus OF-subnode or by means of the MDIO-bus board_info infrastructure (can be utilized in the SJA1105 or Wangxun Tx GBE). The xpcs_create() method then either probes the device on the MDIO bus and gets ID from there, or just uses the custom IDs based on the OF compatible match table or on the platform_data. If no MDIO-device was created my patchset is supposed to preserve the previous semantics: create MDIO-device, probe the device on the MDIO-bus, get device IDs from there. See the next patch for more details: https://lore.kernel.org/netdev/20231205103559.9605-11-fancer.lancer at gmail.com/ > That was attempted a while ago by > Sean Anderson with the Lynx PCS. Are you aware of the fact that even in > the good case in which binding the driver actually works, the user can > then come along and unbind it from the PCS device, and phylink isn't > prepared to handle that, so it will crash the kernel upon the next > phylink_pcs call? To be honest I didn't consider the driver bind/unbind option. But my case a bit different. DW XPCS MDIO-device is supposed to be created automatically by means of the DW XPCS MI driver from the DT-nodes hierarchy like this: mdio at 1f05d000 { compatible = "snps,dw-xpcs-mi"; reg = <0 0x1f05d000 0 0x1000>; xgmac_pcs: ethernet-pcs at 0 { compatible = "snps,dw-xpcs"; reg = <0>; }; }; The platform-device is created for the mdio at 1f05d000 node for which the DW XPCS MI driver is loaded, which calls the devm_of_mdiobus_register() in the probe() method which registers the MDIO-bus and then creates the MDIO-device from the ethernet-pcs at 0 node. The DW XPCS MDIO-device driver is attached to that MDIO-device then. In such model the PCS can be supplied to the DW *MAC via the "pcs-handle = &xgmac_pcs" property. Regarding the current semantics it's preserved in the framework of the xpcs_create_byaddr() method (former xpcs_create_mdiodev()) by means of the next code snippet: if (mdiobus_is_registered_device(bus, addr)) { mdiodev = bus->mdio_map[addr]; mdio_device_get(mdiodev); } else { mdiodev = mdio_device_create(bus, addr); if (IS_ERR(mdiodev)) return ERR_CAST(mdiodev); } Device can be automatically created if before registering the MDIO-bus the xpcs_create_byaddr() caller registered the MDIO-device board info by means of the mdiobus_register_board_info() method. In addition to that it's now possible to supply some custom data (custom device IDs in my implementation) to the XPCS driver by means of the mdio_board_info.platform_data field. See the next patch for reference: https://lore.kernel.org/netdev/20231205103559.9605-14-fancer.lancer at gmail.com So what the difference with the Lynx PCS is that in my case the MDIO-device is created automatically as a result of the DW XPCS MI MDIO-bus registration. Additionally I implemented the MDIO-device creation based on the MDIO-board-info, thus there won't be need in the calling mdio_device_create() on each xpcs_create_mdiodev() invocation. The later part isn't that important in the framework of this conversation, but just so you be aware. Regarding the driver bind/unbind. As I said I didn't actually consider that option. On the other hand my DW XPCS MDIO-device driver doesn't do actual probe() or remove(). The only implemented thing is the of_device_id table, which is used to assign PCS and PMA IDs if required based on the DT compatible property. So I can easily drop any MDIO device-driver part and parse the of_device_id table right in the xpcs_create_bynode(). From that perspective my implementation won't differ much from the Lynx PCS design. The only difference will be is the way the MDIO-bus is created and registered. In case of Lynx PCS the bus is created by the MAC-driver itself. In my case DW XPCS MI is currently created in the framework of the separate platform driver. Do you think it would be better to follow the Lynx design pattern in order to get rid from the possibility of the DW XPCS MI driver being unbound behind the STMMAC+XPCS couple back? In this case the Dw MAC DT-node hierarchy would look like this: xgmac: ethernet at 1f054000 { compatible = "snps,dwxgmac"; reg = <0 0x1f054000 0 0x4000>; reg-names = "stmmaceth"; ranges; ... pcs-handle = &xgmac_pcs; // DW XPCS MI to access the DW XPCS attached to the device mdio at 1f05d000 { compatible = "snps,dwmac-mi"; reg = <0 0x1f05d000 0 0x1000>; xgmac_pcs: ethernet-pcs at 0 { compatible = "snps,dw-xpcs"; reg = <0>; }; }; // Normal MDIO-bus to access external PHYs (it's also called // as SMA - Station Management Agent - by Synopsys) mdio { compatible = "snps,dwmac-mdio"; #address-cells = <1>; #size-cells = <0>; }; }; I actually thought to use that hardware description pattern instead, but after some meditation around that I decided that having the DW XPCS device defined separately from the DW MAC node seemed better at least from the code separation point of view. Now I think that it wasn't the best decision. DW XPCS is always attached to the DW XGMAC controller. So it would be more correct having it defined as a sub-node. It would also helped to avoid the platform device driver bind/unbind problem. What do you think? Should I re-design my patchset to be supporting the design above? (After having conversion with you I am more inclined to do that now than to stick with the currently implemented solution.) > > The pcs-rzn1-miic.c driver puts a device_link to the MAC to at least > tear down the whole thing when the PCS is unbound, which is saner than > crashing the kernel. I don't see the equivalent protection mechanism here? You are right. I don't have any equivalent protection here. Thanks for suggesting a solution. > > Can't the xpcs continue to live without a bound driver? Having a > compatible string in the OF description is perfectly fine though, > and should absolutely not preclude that. As I explained above Dw XPCS device can live without a bound driver because the DW XPCS MDIO-driver doesn't do much but merely gets to be bound based on the of_device_id table. In my case the problem is in the DW XPCS MI driver which indeed can be detached. Please see my long-read text above. -Serge(y) From fancer.lancer at gmail.com Sat Dec 9 03:07:42 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Fri, 8 Dec 2023 19:07:42 +0300 Subject: [PATCH net-next 09/16] net: mdio: Add Synopsys DW XPCS management interface support In-Reply-To: <19ebc244-6d79-4e12-8ac4-fcf046106a07@lunn.ch> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-10-fancer.lancer@gmail.com> <20231205133205.3309ab91@device.home> <15e6857a-b1d1-465a-945e-6f31edac62fb@lunn.ch> <19ebc244-6d79-4e12-8ac4-fcf046106a07@lunn.ch> Message-ID: On Thu, Dec 07, 2023 at 03:54:08PM +0100, Andrew Lunn wrote: > On Thu, Dec 07, 2023 at 04:35:47PM +0300, Serge Semin wrote: > > Hi Andrew > > > > On Wed, Dec 06, 2023 at 06:01:30PM +0100, Andrew Lunn wrote: > > > > > You shouldn't use inline in C files, only in headers. > > > > > > > > Could you please clarify why? I failed to find such requirement in the > > > > coding style doc. Moreover there are multiple examples of using the > > > > static-inline-ers in the C files in the kernel including the net/mdio > > > > subsystem. > > > > > > > > The compiler does a better job at deciding what to inline than we > > > humans do. If you can show the compiler is doing it wrong, then we > > > might accept them. > > > > In general I would have agreed with you especially if the methods were > > heavier than what they are: > > static inline ptrdiff_t dw_xpcs_mmio_addr_format(int dev, int reg) > > { > > return FIELD_PREP(0x1f0000, dev) | FIELD_PREP(0xffff, reg); > > } > > > > static inline u16 dw_xpcs_mmio_addr_page(ptrdiff_t csr) > > { > > return FIELD_GET(0x1fff00, csr); > > } > > > > static inline ptrdiff_t dw_xpcs_mmio_addr_offset(ptrdiff_t csr) > > { > > return FIELD_GET(0xff, csr); > > } > > > > > But in general, netdev does not like inline in .C > > > file. > > > > I see. I'll do as you say if you don't change your mind after my > > reasoning below. > > > > > Also, nothing in MDIO is hot path, it spends a lot of time > > > waiting for a slow bus. So inline is likely to just bloat the code for > > > no gain. > > > > I would have been absolutely with you in this matter, if we were talking > > about a normal MDIO bus. In this case the devices are accessed over > > the system IO-memory. So the bus isn't that slow. > > O.K, so its not slow. But how often is it used? PHYs tend to get > polled once a second if interrupts are not used. But is the PCS also > polled at the same time? Does this optimisation make a noticeable > difference at once per second? Do you have a requirement that the > system boots very very fast, and this optimisation makes a difference > when there is heavier activity on the PCS at boot? Is the saving > noticeable, when auto-neg takes a little over 1 second. > > The best way to make your case is show real world requirements and > benchmark results. You do know how to well define your point.) Polling is what currently implemented in the XPCS driver indeed. So in this case such small optimization won't be even noticeable. Although theoretically the IO-access could be performed on the fast paths, in the IRQ context, but it could be relevant only if the DW XPCS device had the IRQ feature activated on the particular platform and the DW XPCS driver supported it. But seeing the driver currently doesn't support it and the DW XPCS could be also found on the DW MAC SMA MDIO bus (non-memory-mapped case), always handling IRQ in the hardware IRQ context would be wrong. Splitting up the handlers would be over-complication for indeed doubtful reason, since inlining those methods won't gain significant performance even in that case. And of course I don't have such strict requirements as you say. So I'll drop the inline keywords then. Thank you very much for having kept discussing the topic in order to fully clarify it for me, even though the issue could have seemed unimportant to spend time for. -Serge(y) > > Andrew From olteanv at gmail.com Sat Dec 9 03:33:43 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Fri, 8 Dec 2023 18:33:43 +0200 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> <20231205122316.ihhpklv222f5giz3@skbuf> Message-ID: <20231208163343.5s74bmirfna3o7yw@skbuf> On Fri, Dec 08, 2023 at 05:11:20PM +0300, Serge Semin wrote: > My idea was to reuse the mdio_device which has already been created > either by means of the MDIO-bus OF-subnode or by means of the MDIO-bus > board_info infrastructure (can be utilized in the SJA1105 or Wangxun > Tx GBE). The xpcs_create() method then either probes the device on the MDIO > bus and gets ID from there, or just uses the custom IDs based on the > OF compatible match table or on the platform_data. If no MDIO-device > was created my patchset is supposed to preserve the previous > semantics: create MDIO-device, probe the device on the MDIO-bus, get > device IDs from there. See the next patch for more details: > https://lore.kernel.org/netdev/20231205103559.9605-11-fancer.lancer at gmail.com/ > > > That was attempted a while ago by > > Sean Anderson with the Lynx PCS. Are you aware of the fact that even in > > the good case in which binding the driver actually works, the user can > > then come along and unbind it from the PCS device, and phylink isn't > > prepared to handle that, so it will crash the kernel upon the next > > phylink_pcs call? > > To be honest I didn't consider the driver bind/unbind option. But my > case a bit different. DW XPCS MDIO-device is supposed to be created > automatically by means of the DW XPCS MI driver from the DT-nodes > hierarchy like this: > mdio at 1f05d000 { > compatible = "snps,dw-xpcs-mi"; > reg = <0 0x1f05d000 0 0x1000>; > > xgmac_pcs: ethernet-pcs at 0 { > compatible = "snps,dw-xpcs"; > reg = <0>; > }; > }; > The platform-device is created for the mdio at 1f05d000 node for which > the DW XPCS MI driver is loaded, which calls the > devm_of_mdiobus_register() in the probe() method which registers the > MDIO-bus and then creates the MDIO-device from the ethernet-pcs at 0 > node. The DW XPCS MDIO-device driver is attached to that MDIO-device > then. In such model the PCS can be supplied to the DW *MAC via the > "pcs-handle = &xgmac_pcs" property. > > Regarding the current semantics it's preserved in the framework of the > xpcs_create_byaddr() method (former xpcs_create_mdiodev()) by means of > the next code snippet: > if (mdiobus_is_registered_device(bus, addr)) { > mdiodev = bus->mdio_map[addr]; > mdio_device_get(mdiodev); > } else { > mdiodev = mdio_device_create(bus, addr); > if (IS_ERR(mdiodev)) > return ERR_CAST(mdiodev); > } > Device can be automatically created if before registering the MDIO-bus > the xpcs_create_byaddr() caller registered the MDIO-device board info > by means of the mdiobus_register_board_info() method. In addition to > that it's now possible to supply some custom data (custom device IDs > in my implementation) to the XPCS driver by means of the > mdio_board_info.platform_data field. See the next patch for > reference: > https://lore.kernel.org/netdev/20231205103559.9605-14-fancer.lancer at gmail.com > > So what the difference with the Lynx PCS is that in my case the > MDIO-device is created automatically as a result of the DW XPCS MI > MDIO-bus registration. Additionally I implemented the MDIO-device > creation based on the MDIO-board-info, thus there won't be need in the > calling mdio_device_create() on each xpcs_create_mdiodev() invocation. > The later part isn't that important in the framework of this > conversation, but just so you be aware. It's not really different, though. You can connect to the Lynx PCS both ways, see dpaa2_pcs_create() which also searches for a pcs-handle before calling lynx_pcs_create_fwnode(). What's subtly different is that we don't (yet) have "fsl,lynx-pcs" compatible strings in the device tree. So the MDIO controller will register the PCS devices as struct phy_device (which still have an underlying struct mdio_device). The PCS layer connects to the underlying struct mdio_device, and the phy_device on top remains unconnected to any phylib/phylink MAC driver. That is confusing, I should really get to adding those compatible strings to suppress the phy_device creation. > Regarding the driver bind/unbind. As I said I didn't actually consider > that option. On the other hand my DW XPCS MDIO-device driver doesn't > do actual probe() or remove(). The only implemented thing is the > of_device_id table, which is used to assign PCS and PMA IDs if > required based on the DT compatible property. So I can easily drop any > MDIO device-driver part and parse the of_device_id table right in the > xpcs_create_bynode(). From that perspective my implementation won't > differ much from the Lynx PCS design. The only difference will be is > the way the MDIO-bus is created and registered. In case of Lynx PCS > the bus is created by the MAC-driver itself. Nope, not true. Follow the pcs-handle in arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi. > In my case DW XPCS MI is currently created in the framework of the > separate platform driver. Do you think it would be better to follow > the Lynx design pattern in order to get rid from the possibility of > the DW XPCS MI driver being unbound behind the STMMAC+XPCS couple > back? I think you actually pointed out a flaw in the Lynx PCS design too. Actually, it is a larger flaw in the kernel. You can also unbind the MDIO bus which holds the phy_device, and phylib (and therefore also phylink) won't expect that either, so it will crash. > In this case the Dw MAC DT-node hierarchy would look like this: > > xgmac: ethernet at 1f054000 { > compatible = "snps,dwxgmac"; > reg = <0 0x1f054000 0 0x4000>; > reg-names = "stmmaceth"; > ranges; > > ... > > pcs-handle = &xgmac_pcs; > > // DW XPCS MI to access the DW XPCS attached to the device > mdio at 1f05d000 { > compatible = "snps,dwmac-mi"; > reg = <0 0x1f05d000 0 0x1000>; > > xgmac_pcs: ethernet-pcs at 0 { > compatible = "snps,dw-xpcs"; > reg = <0>; > }; > }; > > // Normal MDIO-bus to access external PHYs (it's also called > // as SMA - Station Management Agent - by Synopsys) > mdio { > compatible = "snps,dwmac-mdio"; > #address-cells = <1>; > #size-cells = <0>; > }; > }; > > I actually thought to use that hardware description pattern instead, > but after some meditation around that I decided that having the DW > XPCS device defined separately from the DW MAC node seemed better at > least from the code separation point of view. Now I think that it > wasn't the best decision. DW XPCS is always attached to the DW XGMAC > controller. So it would be more correct having it defined as a > sub-node. It would also helped to avoid the platform device driver > bind/unbind problem. > > What do you think? Should I re-design my patchset to be supporting the > design above? (After having conversion with you I am more inclined to > do that now than to stick with the currently implemented solution.) I think that the placement of the "mdio" node as lateral vs subordinate to the "ethernet" node would have fixed the issue by mistake. We should be looking at it as a structural problem of the kernel instead. Don't let it influence what you believe should be the correct design. > > The pcs-rzn1-miic.c driver puts a device_link to the MAC to at least > > tear down the whole thing when the PCS is unbound, which is saner than > > crashing the kernel. I don't see the equivalent protection mechanism here? > > You are right. I don't have any equivalent protection here. Thanks for > suggesting a solution. I think that a device link between the "ethernet" device and the "mdio" device (controller, parent of the PHY or PCS), if the Ethernet is not a parent of the MDIO controller, could also solve that. But it would also require ACK from PHY maintainers, who may have grander plans to address this snag. > > Can't the xpcs continue to live without a bound driver? Having a > > compatible string in the OF description is perfectly fine though, > > and should absolutely not preclude that. > > As I explained above Dw XPCS device can live without a bound driver > because the DW XPCS MDIO-driver doesn't do much but merely gets to be > bound based on the of_device_id table. In my case the problem is in > the DW XPCS MI driver which indeed can be detached. Please see my > long-read text above. Yeah, common design, common problem. From andi.shyti at kernel.org Sun Dec 10 07:28:10 2023 From: andi.shyti at kernel.org (Andi Shyti) Date: Sat, 9 Dec 2023 21:28:10 +0100 Subject: [PATCH v3 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231208033142.1673232-2-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-2-quan@os.amperecomputing.com> Message-ID: <20231209202810.r7kkz2hlaonyibha@zenone.zhora.eu> Hi Quan, On Fri, Dec 08, 2023 at 10:31:41AM +0700, Quan Nguyen wrote: > Some masters may drive the transfers with low enough latency between > the nak/stop phase of the current command and the start/address phase > of the following command that the interrupts are coalesced by the > time we process them. > Handle the stop conditions before processing SLAVE_MATCH to fix the > complaints that sometimes occur below. > > "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected > 0x00000086, but was 0x00000084" > > Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") > Signed-off-by: Quan Nguyen Reviewed-by: Andi Shyti Thanks, Andi From andi.shyti at kernel.org Sun Dec 10 07:44:55 2023 From: andi.shyti at kernel.org (Andi Shyti) Date: Sat, 9 Dec 2023 21:44:55 +0100 Subject: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231208033142.1673232-3-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-3-quan@os.amperecomputing.com> Message-ID: <20231209204455.jxize3muvx7hhpos@zenone.zhora.eu> Hi Quan, [...] > - /* Ack all interrupts except for Rx done */ > - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, > - bus->base + ASPEED_I2C_INTR_STS_REG); > + > + /* > + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would indicate HW to > + * start receiving or sending new data, and this may cause a race condition > + * as the irq handler has not yet handled these irqs but is being acked. > + * Let's ack them late at the end of the irq handler when those are truly processed. > + */ > + irq_ack_last = ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK; > + writel(irq_received & ~irq_ack_last, bus->base + ASPEED_I2C_INTR_STS_REG); I like Andrews suggestion of having irq_ack_last as a define that is already negated, instead of negating it in the writel, which makes it a bit difficult to read. Besides, ack_last, as a name is not very meaningful, I'd rather call it irq_ack_rx_tx (or something similar). But I'm not going to block it for this, up to you if you want to send a new version. Reviewed-by: Andi Shyti Thanks, Andi From u.kleine-koenig at pengutronix.de Mon Dec 11 09:12:23 2023 From: u.kleine-koenig at pengutronix.de (=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=) Date: Sun, 10 Dec 2023 23:12:23 +0100 Subject: [PATCH 08/12] hwrng: npcm - Convert to platform remove callback returning void In-Reply-To: References: Message-ID: The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-K?nig --- drivers/char/hw_random/npcm-rng.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/char/hw_random/npcm-rng.c b/drivers/char/hw_random/npcm-rng.c index 8a304b754217..bce8c4829a1f 100644 --- a/drivers/char/hw_random/npcm-rng.c +++ b/drivers/char/hw_random/npcm-rng.c @@ -126,15 +126,13 @@ static int npcm_rng_probe(struct platform_device *pdev) return 0; } -static int npcm_rng_remove(struct platform_device *pdev) +static void npcm_rng_remove(struct platform_device *pdev) { struct npcm_rng *priv = platform_get_drvdata(pdev); devm_hwrng_unregister(&pdev->dev, &priv->rng); pm_runtime_disable(&pdev->dev); pm_runtime_set_suspended(&pdev->dev); - - return 0; } #ifdef CONFIG_PM @@ -178,7 +176,7 @@ static struct platform_driver npcm_rng_driver = { .of_match_table = of_match_ptr(rng_dt_id), }, .probe = npcm_rng_probe, - .remove = npcm_rng_remove, + .remove_new = npcm_rng_remove, }; module_platform_driver(npcm_rng_driver); -- 2.42.0 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:23 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:23 +0800 Subject: [PATCH linux dev-6.6 v1 00/14] Add i2c-mux and eeprom devices for Meta Yosemite 4 Message-ID: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Changelog: - Add gpio and eeprom behind i2c-mux - Remove redundant idle-state setting for i2c-mux - Enable adc 15, wdt2,spi gpio for yosemite4 use - Revise quad mode to dual mode to avoid WP pin influnece the SPI - Revise power sensor adm1281 for yosemite4 schematic change - Add gpio pca9506 I/O expander for yosemite4 use - remove space for adm1272 compatible - enable interrupt setting for pca9555 - add eeprom for yosemite4 medusa board/BSM use - remove temperature sensor for yosemite4 schematic change - add power sensor for power module reading - Revise adc128d818 adc mode for yosemite4 schematic change - Revise ina233 for yosemite4 schematic change - Remove idle state setting for yosemite4 NIC connection - Initialize bmc gpio state - Revise mx31790 fan tach config - Add mctp config for NIC - Support mux to cpld - Revise gpio name Delphine CC Chiu (14): ARM: dts: aspeed: yosemite4: Revise i2c-mux devices ARM: dts: aspeed: yosemite4: Enable adc15 ARM: dts: aspeed: yosemite4: Enable spi-gpio setting ARM: dts: aspeed: yosemite4: Enable watchdog2 ARM: dts: aspeed: yosemite4: Revise quad mode to dual mode ARM: dts: aspeed: yosemite4: Revise power sensor adm1281 for schematic change ARM: dts: aspeed: yosemite4: Add gpio pca9506 ARM: dts: aspeed: yosemite4: Revise i2c11 and i2c12 schematic change ARM: dts: aspeed: yosemite4: Revise i2c14 and i2c15 schematic change ARM: dts: aspeed: yosemite4: Initialize bmc gpio state ARM: dts: aspeed: yosemite4: Revise mx31790 fan tach config ARM: dts: aspeed: yosemite4: add mctp config for NIC ARM: dts: aspeed: yosemite4: support mux to cpld ARM: dts: aspeed: yosemite4: Revise gpio name .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 1215 +++++++++++++++-- 1 file changed, 1091 insertions(+), 124 deletions(-) -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:24 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:24 +0800 Subject: [PATCH linux dev-6.6 v1 01/14] ARM: dts: aspeed: yosemite4: Revise i2c-mux devices In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-2-Delphine_CC_Chiu@wiwynn.com> Revise Yosemite 4 devicetree for devices behind i2c-mux - Add gpio and eeprom behind i2c-mux - Remove redundant idle-state setting for i2c-mux Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 381 ++++++++++++++++-- 1 file changed, 347 insertions(+), 34 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 64075cc41d92..a5b4585e81e6 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -17,6 +17,25 @@ aliases { serial6 = &uart7; serial7 = &uart8; serial8 = &uart9; + + i2c16 = &imux16; + i2c17 = &imux17; + i2c18 = &imux18; + i2c19 = &imux19; + i2c20 = &imux20; + i2c21 = &imux21; + i2c22 = &imux22; + i2c23 = &imux23; + i2c24 = &imux24; + i2c25 = &imux25; + i2c26 = &imux26; + i2c27 = &imux27; + i2c28 = &imux28; + i2c29 = &imux29; + i2c30 = &imux30; + i2c31 = &imux31; + i2c32 = &imux32; + i2c33 = &imux33; }; chosen { @@ -259,9 +278,109 @@ &i2c8 { bus-frequency = <400000>; i2c-mux at 70 { compatible = "nxp,pca9544"; - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x70>; + + imux16: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux17: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux18: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux19: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; }; }; @@ -270,15 +389,174 @@ &i2c9 { bus-frequency = <400000>; i2c-mux at 71 { compatible = "nxp,pca9544"; - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x71>; + + imux20: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux21: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux22: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux23: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; }; }; &i2c10 { status = "okay"; bus-frequency = <400000>; + i2c-mux at 74 { + compatible = "nxp,pca9544"; + i2c-mux-idle-disconnect; + reg = <0x74>; + + imux28: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 24 { + compatible = "nxp,pca9506"; + reg = <0x24>; + gpio-controller; + #gpio-cells = <2>; + gpio-line-names = + "","","","", + "NIC0_MAIN_PWR_EN","NIC1_MAIN_PWR_EN", + "NIC2_MAIN_PWR_EN","NIC3_MAIN_PWR_EN", + "","","","","","","","", + "","","","","","","","", + "","","","","","","",""; + }; + }; + + imux29: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; }; &i2c11 { @@ -433,16 +711,14 @@ eeprom at 51 { reg = <0x51>; }; - i2c-mux at 71 { - compatible = "nxp,pca9846"; + i2c-mux at 74 { + compatible = "nxp,pca9546"; #address-cells = <1>; #size-cells = <0>; - - idle-state = <0>; i2c-mux-idle-disconnect; - reg = <0x71>; + reg = <0x74>; - i2c at 0 { + imux30: i2c at 0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; @@ -450,26 +726,26 @@ i2c at 0 { adc at 1f { compatible = "ti,adc128d818"; reg = <0x1f>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; pwm at 20{ - compatible = "max31790"; + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; reg = <0x20>; - #address-cells = <1>; - #size-cells = <0>; }; gpio at 22{ compatible = "ti,tca6424"; reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; }; - pwm at 23{ - compatible = "max31790"; - reg = <0x23>; - #address-cells = <1>; - #size-cells = <0>; + pwm at 2f{ + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; + reg = <0x2f>; }; adc at 33 { @@ -492,34 +768,34 @@ gpio at 61 { }; }; - i2c at 1 { + imux31: i2c at 1 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <1>; adc at 1f { compatible = "ti,adc128d818"; reg = <0x1f>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; pwm at 20{ - compatible = "max31790"; + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; reg = <0x20>; - #address-cells = <1>; - #size-cells = <0>; }; gpio at 22{ compatible = "ti,tca6424"; reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; }; - pwm at 23{ - compatible = "max31790"; - reg = <0x23>; - #address-cells = <1>; - #size-cells = <0>; + pwm at 2f{ + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; + reg = <0x2f>; }; adc at 33 { @@ -547,12 +823,10 @@ i2c-mux at 73 { compatible = "nxp,pca9544"; #address-cells = <1>; #size-cells = <0>; - - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x73>; - i2c at 0 { + imux32: i2c at 0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; @@ -563,10 +837,10 @@ adc at 35 { }; }; - i2c at 1 { + imux33: i2c at 1 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <1>; adc at 35 { compatible = "maxim,max11617"; @@ -589,9 +863,48 @@ mctp at 10 { i2c-mux at 72 { compatible = "nxp,pca9544"; - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x72>; + + imux24: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; + + imux25: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; + + imux26: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; + + imux27: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:25 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:25 +0800 Subject: [PATCH linux dev-6.6 v1 02/14] ARM: dts: aspeed: yosemite4: Enable adc15 In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-3-Delphine_CC_Chiu@wiwynn.com> Enable Yosemite 4 adc15 config Signed-off-by: Delphine CC Chiu --- arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index a5b4585e81e6..c32736fbaf70 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -51,7 +51,7 @@ iio-hwmon { compatible = "iio-hwmon"; io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, <&adc0 7>, - <&adc1 0>, <&adc1 1>; + <&adc1 0>, <&adc1 1>, <&adc1 7>; }; }; @@ -920,10 +920,10 @@ &pinctrl_adc4_default &pinctrl_adc5_default &adc1 { ref_voltage = <2500>; status = "okay"; - pinctrl-0 = <&pinctrl_adc8_default &pinctrl_adc9_default>; + pinctrl-0 = <&pinctrl_adc8_default &pinctrl_adc9_default + &pinctrl_adc15_default>; }; - &ehci0 { status = "okay"; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:26 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:26 +0800 Subject: [PATCH linux dev-6.6 v1 03/14] ARM: dts: aspeed: yosemite4: Enable spi-gpio setting In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-4-Delphine_CC_Chiu@wiwynn.com> enable spi-gpio setting for spi flash Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index c32736fbaf70..0449a7e36ff6 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -53,6 +53,24 @@ iio-hwmon { <&adc0 4>, <&adc0 5>, <&adc0 6>, <&adc0 7>, <&adc1 0>, <&adc1 1>, <&adc1 7>; }; + + spi_gpio: spi-gpio { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio0 ASPEED_GPIO(X, 3) GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio0 ASPEED_GPIO(X, 4) GPIO_ACTIVE_HIGH>; + gpio-miso = <&gpio0 ASPEED_GPIO(X, 5) GPIO_ACTIVE_HIGH>; + num-chipselects = <1>; + cs-gpios = <&gpio0 ASPEED_GPIO(X, 0) GPIO_ACTIVE_LOW>; + + tpmdev at 0 { + compatible = "tcg,tpm_tis-spi"; + spi-max-frequency = <33000000>; + reg = <0>; + }; + }; }; &uart1 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:27 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:27 +0800 Subject: [PATCH linux dev-6.6 v1 04/14] ARM: dts: aspeed: yosemite4: Enable watchdog2 In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-5-Delphine_CC_Chiu@wiwynn.com> enable watchdog2 setting Signed-off-by: Delphine CC Chiu --- arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 0449a7e36ff6..0e9095c83a59 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -120,6 +120,13 @@ &wdt1 { aspeed,ext-pulse-duration = <256>; }; +&wdt2 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_wdtrst2_default>; + aspeed,reset-type = "system"; +}; + &mac2 { status = "okay"; pinctrl-names = "default"; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:28 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:28 +0800 Subject: [PATCH linux dev-6.6 v1 05/14] ARM: dts: aspeed: yosemite4: Revise quad mode to dual mode In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-6-Delphine_CC_Chiu@wiwynn.com> Revise quad mode to dual mode to avoid WP pin influnece the SPI Signed-off-by: Delphine CC Chiu --- .../arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 0e9095c83a59..7fe80ad271aa 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -149,15 +149,17 @@ flash at 0 { status = "okay"; m25p,fast-read; label = "bmc"; - spi-rx-bus-width = <4>; + spi-tx-bus-width = <2>; + spi-rx-bus-width = <2>; spi-max-frequency = <50000000>; -#include "openbmc-flash-layout-64.dtsi" +#include "openbmc-flash-layout-128.dtsi" }; flash at 1 { status = "okay"; m25p,fast-read; label = "bmc2"; - spi-rx-bus-width = <4>; + spi-tx-bus-width = <2>; + spi-rx-bus-width = <2>; spi-max-frequency = <50000000>; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:30 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:30 +0800 Subject: [PATCH linux dev-6.6 v1 07/14] ARM: dts: aspeed: yosemite4: Add gpio pca9506 In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-8-Delphine_CC_Chiu@wiwynn.com> Add gpio pca9506 I/O expander for yv4 use Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 7f0134fcee57..da413325ce30 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -175,6 +175,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -193,6 +221,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -211,6 +267,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -229,6 +313,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -247,6 +359,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -265,6 +405,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -283,6 +451,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -301,6 +497,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -683,6 +907,33 @@ rtc at 6f { &i2c13 { status = "okay"; bus-frequency = <400000>; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; }; &i2c14 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:29 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:29 +0800 Subject: [PATCH linux dev-6.6 v1 06/14] ARM: dts: aspeed: yosemite4: Revise power sensor adm1281 for schematic change In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-7-Delphine_CC_Chiu@wiwynn.com> Revise power sensor adm1281 for yosemite4 schematic change Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 7fe80ad271aa..7f0134fcee57 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -176,8 +176,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -193,8 +194,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -210,8 +212,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -227,8 +230,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -244,8 +248,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -261,8 +266,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -278,8 +284,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -295,8 +302,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:33 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:33 +0800 Subject: [PATCH linux dev-6.6 v1 10/14] ARM: dts: aspeed: yosemite4: Initialize bmc gpio state In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-11-Delphine_CC_Chiu@wiwynn.com> Initialize bmc gpio state Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index ed2b1200603d..eb3687bfd632 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1271,6 +1271,7 @@ temperature-sensor at 1f { }; }; + &adc0 { ref_voltage = <2500>; status = "okay"; @@ -1298,3 +1299,197 @@ &ehci1 { &uhci { status = "okay"; }; + +&sgpiom0 { + status = "okay"; + ngpios = <128>; + bus-frequency = <48000>; +}; + +&gpio0 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_gpiu2_default &pinctrl_gpiu3_default + &pinctrl_gpiu4_default &pinctrl_gpiu5_default + &pinctrl_gpiu6_default>; + gpio-line-names = + /*A0-A7*/ "","","","","","","","", + /*B0-B7*/ "FLT_HSC_SERVER_SLOT8_N","AC_ON_OFF_BTN_CPLD_SLOT5_N", + "PWRGD_SLOT1_STBY","PWRGD_SLOT2_STBY", + "PWRGD_SLOT3_STBY","PWRGD_SLOT4_STBY","","", + /*C0-C7*/ "PRSNT_NIC3_N","","","","FM_NIC0_WAKE_N", + "FM_NIC1_WAKE_N","","RST_PCIE_SLOT2_N", + /*D0-D7*/ "","","","","","","","", + /*E0-E7*/ "PRSNT_NIC1_N","PRSNT_NIC2_N","","RST_PCIE_SLOT1_N", + "","","","", + /*F0-F7*/ "FM_RESBTN_SLOT1_BMC_N","FM_RESBTN_SLOT2_BMC_N", + "FM_RESBTN_SLOT3_BMC_N","FM_RESBTN_SLOT4_BMC_N", + "PRSNT_SB_SLOT1_N","PRSNT_SB_SLOT2_N", + "PRSNT_SB_SLOT3_N","PRSNT_SB_SLOT4_N", + /*G0-G7*/ "","","","","","","","", + /*H0-H7*/ "","","","","","","","", + /*I0-I7*/ "","","","","","ALT_MEDUSA_ADC_N", + "ALT_SMB_BMC_CPLD2_N", + "INT_SPIDER_ADC_R_N", + /*J0-J7*/ "","","","","","","","", + /*K0-K7*/ "","","","","","","","", + /*L0-L7*/ "","","","","","","ALT_MEDUSA_P12V_EFUSE_N","", + /*M0-M7*/ "EN_NIC0_POWER_BMC_R","EN_NIC1_POWER_BMC_R", + "INT_MEDUSA_IOEXP_TEMP_N","FLT_P12V_NIC0_N", + "INT_SMB_BMC_SLOT1_4_BMC_N", + "AC_ON_OFF_BTN_CPLD_SLOT6_N","","", + /*N0-N7*/ "FLT_HSC_SERVER_SLOT1_N","FLT_HSC_SERVER_SLOT2_N", + "FLT_HSC_SERVER_SLOT3_N","FLT_HSC_SERVER_SLOT4_N", + "FM_BMC_READY_R2","FLT_P12V_STBY_BMC_N","","", + /*O0-O7*/ "AC_ON_OFF_BTN_CPLD_SLOT8_N","RST_SMB_NIC1_R_N", + "RST_SMB_NIC2_R_N","RST_SMB_NIC3_R_N", + "FLT_P3V3_NIC2_N","FLT_P3V3_NIC3_N", + "","", + /*P0-P7*/ "ALT_SMB_BMC_CPLD1_N","'BTN_BMC_R2_N", + "EN_P3V_BAT_SCALED_R","PWRGD_P5V_USB_BMC", + "FM_BMC_RTCRST_R","RST_USB_HUB_R_N", + "FLAG_P5V_USB_BMC_N","", + /*Q0-Q7*/ "AC_ON_OFF_BTN_CPLD_SLOT1_N","AC_ON_OFF_BTN_CPLD_SLOT2_N", + "AC_ON_OFF_BTN_CPLD_SLOT3_N","AC_ON_OFF_BTN_CPLD_SLOT4_N", + "PRSNT_SB_SLOT5_N","PRSNT_SB_SLOT6_N", + "PRSNT_SB_SLOT7_N","PRSNT_SB_SLOT8_N", + /*R0-R7*/ "AC_ON_OFF_BTN_CPLD_SLOT7_N","INT_SMB_BMC_SLOT5_8_BMC_N", + "FM_PWRBRK_NIC_BMC_R2","RST_PCIE_SLOT4_N", + "RST_PCIE_SLOT5_N","RST_PCIE_SLOT6_N", + "RST_PCIE_SLOT7_N","RST_PCIE_SLOT8_N", + /*S0-S7*/ "FM_NIC2_WAKE_N","FM_NIC3_WAKE_N", + "EN_NIC3_POWER_BMC_R","SEL_BMC_JTAG_MUX_R", + "","ALT_P12V_AUX_N","FAST_PROCHOT_N", + "SPI_WP_DISABLE_STATUS_R_N", + /*T0-T7*/ "","","","","","","","", + /*U0-U7*/ "","","FLT_P3V3_NIC1_N","FLT_P12V_NIC1_N", + "FLT_P12V_NIC2_N","FLT_P12V_NIC3_N", + "FLT_P3V3_NIC0_N","", + /*V0-V7*/ "FM_RESBTN_SLOT5_BMC_N","FM_RESBTN_SLOT6_BMC_N", + "FM_RESBTN_SLOT7_BMC_N","FM_RESBTN_SLOT8_BMC_N", + "","","","", + /*W0-W7*/ "PRSNT_TPM_BMC_N","PRSNT_OCP_DEBUG_BMC_N","ALT_TEMP_BMC_N","ALT_RTC_BMC_N", + "","","","", + /*X0-X7*/ "","LT_HSC_SERVER_SLOT6_N","FLT_HSC_SERVER_SLOT7_N","","","", + "PWRGD_SLOT5_STBY","PWRGD_SLOT6_STBY", + /*Y0-Y7*/ "","","SPI_LOCK_REQ_BMC_N","PWRGD_SLOT7_STBY", + "","","EN_NIC2_POWER_BMC_R","", + /*Z0-Z7*/ "EN_P5V_USB_CPLD_R","'FLT_HSC_SERVER_SLOT5_N", + "PWRGD_SLOT8_STBY","","","","",""; + + pin_gpio_b4 { + gpios = ; + input; + }; + pin_gpio_b5 { + gpios = ; + input; + }; + pin_gpio_f0 { + gpios = ; + input; + }; + pin_gpio_f1 { + gpios = ; + input; + }; + pin_gpio_f2 { + gpios = ; + input; + }; + pin_gpio_f3 { + gpios = ; + input; + }; + pin_gpio_f4 { + gpios = ; + input; + }; + pin_gpio_f5 { + gpios = ; + input; + }; + pin_gpio_f6 { + gpios = ; + input; + }; + pin_gpio_f7 { + gpios = ; + input; + }; + pin_gpio_l6 { + gpios = ; + input; + }; + pin_gpio_l7 { + gpios = ; + input; + }; + pin_gpio_s0 { + gpios = ; + input; + }; + pin_gpio_s1 { + gpios = ; + input; + }; + pin_gpio_v0 { + gpios = ; + input; + }; + pin_gpio_v1 { + gpios = ; + input; + }; + pin_gpio_v2 { + gpios = ; + input; + }; + pin_gpio_v3 { + gpios = ; + input; + }; + pin_gpio_w0 { + gpios = ; + input; + }; + pin_gpio_w1 { + gpios = ; + input; + }; + pin_gpio_w2 { + gpios = ; + input; + }; + pin_gpio_w3 { + gpios = ; + input; + }; + pin_gpio_w4 { + gpios = ; + input; + }; + pin_gpio_w5 { + gpios = ; + input; + }; + pin_gpio_w6 { + gpios = ; + input; + }; + pin_gpio_w7 { + gpios = ; + input; + }; + pin_gpio_z3 { + gpios = ; + input; + }; + pin_gpio_z4 { + gpios = ; + input; + }; + pin_gpio_z5 { + gpios = ; + input; + }; +}; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:31 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:31 +0800 Subject: [PATCH linux dev-6.6 v1 08/14] ARM: dts: aspeed: yosemite4: Revise i2c11 and i2c12 schematic change In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-9-Delphine_CC_Chiu@wiwynn.com> Revise i2c11 and i2c12 schematic change: - remove space for adm1272 compatible - enable interrupt setting for pca9555 - add eeprom for yosemite4 medusa board/BSM use - remove temperature sensor for yosemite4 schematic change - add power sensor for power module reading Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 118 ++++++++++++++---- 1 file changed, 93 insertions(+), 25 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index da413325ce30..ccb5ecd8d9a6 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -821,41 +821,94 @@ imux29: i2c at 1 { &i2c11 { status = "okay"; power-sensor at 10 { - compatible = "adi, adm1272"; + compatible = "adi,adm1272"; reg = <0x10>; }; power-sensor at 12 { - compatible = "adi, adm1272"; + compatible = "adi,adm1272"; reg = <0x12>; }; - gpio at 20 { + gpio_ext1: pca9555 at 20 { compatible = "nxp,pca9555"; - reg = <0x20>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; - }; - - gpio at 21 { + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "P48V_OCP_GPIO1","P48V_OCP_GPIO2", + "P48V_OCP_GPIO3","FAN_BOARD_0_REVISION_0_R", + "FAN_BOARD_0_REVISION_1_R","FAN_BOARD_1_REVISION_0_R", + "FAN_BOARD_1_REVISION_1_R","RST_MUX_R_N", + "RST_LED_CONTROL_FAN_BOARD_0_N","RST_LED_CONTROL_FAN_BOARD_1_N", + "RST_IOEXP_FAN_BOARD_0_N","RST_IOEXP_FAN_BOARD_1_N", + "PWRGD_LOAD_SWITCH_FAN_BOARD_0_R","PWRGD_LOAD_SWITCH_FAN_BOARD_1_R", + "",""; + }; + + gpio_ext2: pca9555 at 21 { compatible = "nxp,pca9555"; - reg = <0x21>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; - }; - - gpio at 22 { + reg = <0x21>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "DELTA_MODULE_TYPE","VSENSE_ERR_VDROP_R", + "EN_P48V_AUX_0","EN_P48V_AUX_1", + "MEDUSA_BOARD_REV_0","MEDUSA_BOARD_REV_1", + "MEDUSA_BOARD_REV_2","MEDUSA_BOARD_TYPE", + "HSC_OCP_SLOT_ODD_GPIO1","HSC_OCP_SLOT_ODD_GPIO2", + "HSC_OCP_SLOT_ODD_GPIO3","HSC_OCP_SLOT_EVEN_GPIO1", + "HSC_OCP_SLOT_EVEN_GPIO2","HSC_OCP_SLOT_EVEN_GPIO3", + "ADC_TYPE_0_R","ADC_TYPE_1_R"; + }; + + gpio_ext3: pca9555 at 22 { compatible = "nxp,pca9555"; - reg = <0x22>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; - }; - - gpio at 23 { + reg = <0x22>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "CARD_TYPE_SLOT1","CARD_TYPE_SLOT2", + "CARD_TYPE_SLOT3","CARD_TYPE_SLOT4", + "CARD_TYPE_SLOT5","CARD_TYPE_SLOT6", + "CARD_TYPE_SLOT7","CARD_TYPE_SLOT8", + "OC_P48V_HSC_0_N","FLT_P48V_HSC_0_N", + "PWRGD_P12V_AUX_1","OC_P48V_HSC_1_N", + "FLT_P48V_HSC_1_N","PWRGD_P12V_AUX_1", + "MEDUSA_ADC_EFUSE_TYPE_R","P12V_HSC_TYPE"; + }; + + gpio_ext4: pca9555 at 23 { compatible = "nxp,pca9555"; - reg = <0x23>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; + reg = <0x23>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "HSC1_ALERT1_R_N","HSC2_ALERT1_R_N", + "HSC3_ALERT1_R_N","HSC4_ALERT1_R_N", + "HSC5_ALERT1_R_N","HSC6_ALERT1_R_N", + "HSC7_ALERT1_R_N","HSC8_ALERT1_R_N", + "HSC1_ALERT2_R_N","HSC2_ALERT2_R_N", + "HSC3_ALERT2_R_N","HSC4_ALERT2_R_N", + "HSC5_ALERT2_R_N","HSC6_ALERT2_R_N", + "HSC7_ALERT2_R_N","HSC8_ALERT2_R_N"; + }; + + power-sensor at 40 { + compatible = "mps,mp5023"; + reg = <0x40>; }; temperature-sensor at 48 { @@ -868,19 +921,29 @@ temperature-sensor at 49 { reg = <0x49>; }; - temperature-sensor at 4a { - compatible = "ti,tmp75"; - reg = <0x4a>; + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; }; - temperature-sensor at 4b { - compatible = "ti,tmp75"; - reg = <0x4b>; + power-sensor at 62 { + compatible = "pmbus"; + reg = <0x62>; }; - eeprom at 54 { - compatible = "atmel,24c256"; - reg = <0x54>; + power-sensor at 64 { + compatible = "pmbus"; + reg = <0x64>; + }; + + power-sensor at 65 { + compatible = "pmbus"; + reg = <0x65>; + }; + + power-sensor at 68 { + compatible = "pmbus"; + reg = <0x68>; }; }; @@ -898,6 +961,11 @@ eeprom at 50 { reg = <0x50>; }; + eeprom at 54 { + compatible = "atmel,24c64"; + reg = <0x54>; + }; + rtc at 6f { compatible = "nuvoton,nct3018y"; reg = <0x6f>; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:32 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:32 +0800 Subject: [PATCH linux dev-6.6 v1 09/14] ARM: dts: aspeed: yosemite4: Revise i2c14 and i2c15 schematic change In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-10-Delphine_CC_Chiu@wiwynn.com> Revise i2c14 and i2c15 schematic change: - Revise adc128d818 adc mode for yosemite4 schematic change - Revise ina233 for yosemite4 schematic change - Remove idle state setting for yosemite4 NIC connection Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index ccb5ecd8d9a6..ed2b1200603d 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1010,44 +1010,54 @@ &i2c14 { adc at 1d { compatible = "ti,adc128d818"; reg = <0x1d>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; - adc at 35 { + adc at 36 { compatible = "ti,adc128d818"; - reg = <0x35>; - ti,mode = /bits/ 8 <2>; + reg = <0x36>; + ti,mode = /bits/ 8 <1>; }; adc at 37 { compatible = "ti,adc128d818"; reg = <0x37>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; power-sensor at 40 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x40>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 41 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x41>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 42 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x42>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 43 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x43>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 44 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x44>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; temperature-sensor at 4e { @@ -1217,7 +1227,6 @@ mctp at 10 { i2c-mux at 72 { compatible = "nxp,pca9544"; - i2c-mux-idle-disconnect; reg = <0x72>; imux24: i2c at 0 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:34 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:34 +0800 Subject: [PATCH linux dev-6.6 v1 11/14] ARM: dts: aspeed: yosemite4: Revise mx31790 fan tach config In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-12-Delphine_CC_Chiu@wiwynn.com> Revise fan tach config for max31790 driver change Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index eb3687bfd632..073f27f1e35f 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1095,8 +1095,18 @@ adc at 1f { pwm at 20{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x20>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; gpio at 22{ @@ -1108,8 +1118,18 @@ gpio at 22{ pwm at 2f{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x2f>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; adc at 33 { @@ -1145,8 +1165,18 @@ adc at 1f { pwm at 20{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x20>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; gpio at 22{ @@ -1158,8 +1188,18 @@ gpio at 22{ pwm at 2f{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x2f>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; adc at 33 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:37 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:37 +0800 Subject: [PATCH linux dev-6.6 v1 14/14] ARM: dts: aspeed: yosemite4: Revise gpio name In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-15-Delphine_CC_Chiu@wiwynn.com> Revise gpio name for EVT schematic changes Signed-off-by: Delphine CC Chiu --- .../dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index fdc33bffd467..53e54e71e7dc 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1414,7 +1414,7 @@ &pinctrl_gpiu4_default &pinctrl_gpiu5_default /*B0-B7*/ "FLT_HSC_SERVER_SLOT8_N","AC_ON_OFF_BTN_CPLD_SLOT5_N", "PWRGD_SLOT1_STBY","PWRGD_SLOT2_STBY", "PWRGD_SLOT3_STBY","PWRGD_SLOT4_STBY","","", - /*C0-C7*/ "PRSNT_NIC3_N","","","","FM_NIC0_WAKE_N", + /*C0-C7*/ "","","","","FM_NIC0_WAKE_N", "FM_NIC1_WAKE_N","","RST_PCIE_SLOT2_N", /*D0-D7*/ "","","","","","","","", /*E0-E7*/ "PRSNT_NIC1_N","PRSNT_NIC2_N","","RST_PCIE_SLOT1_N", @@ -1432,16 +1432,15 @@ &pinctrl_gpiu4_default &pinctrl_gpiu5_default /*K0-K7*/ "","","","","","","","", /*L0-L7*/ "","","","","","","ALT_MEDUSA_P12V_EFUSE_N","", /*M0-M7*/ "EN_NIC0_POWER_BMC_R","EN_NIC1_POWER_BMC_R", - "INT_MEDUSA_IOEXP_TEMP_N","FLT_P12V_NIC0_N", + "INT_MEDUSA_IOEXP_TEMP_N","PRSNT_NIC3_N", "INT_SMB_BMC_SLOT1_4_BMC_N", "AC_ON_OFF_BTN_CPLD_SLOT6_N","","", /*N0-N7*/ "FLT_HSC_SERVER_SLOT1_N","FLT_HSC_SERVER_SLOT2_N", "FLT_HSC_SERVER_SLOT3_N","FLT_HSC_SERVER_SLOT4_N", - "FM_BMC_READY_R2","FLT_P12V_STBY_BMC_N","","", + "FM_BMC_READY_R2","RST_SMB_NIC0_R_N","","", /*O0-O7*/ "AC_ON_OFF_BTN_CPLD_SLOT8_N","RST_SMB_NIC1_R_N", "RST_SMB_NIC2_R_N","RST_SMB_NIC3_R_N", - "FLT_P3V3_NIC2_N","FLT_P3V3_NIC3_N", - "","", + "","","","", /*P0-P7*/ "ALT_SMB_BMC_CPLD1_N","'BTN_BMC_R2_N", "EN_P3V_BAT_SCALED_R","PWRGD_P5V_USB_BMC", "FM_BMC_RTCRST_R","RST_USB_HUB_R_N", @@ -1459,9 +1458,8 @@ &pinctrl_gpiu4_default &pinctrl_gpiu5_default "","ALT_P12V_AUX_N","FAST_PROCHOT_N", "SPI_WP_DISABLE_STATUS_R_N", /*T0-T7*/ "","","","","","","","", - /*U0-U7*/ "","","FLT_P3V3_NIC1_N","FLT_P12V_NIC1_N", - "FLT_P12V_NIC2_N","FLT_P12V_NIC3_N", - "FLT_P3V3_NIC0_N","", + /*U0-U7*/ "","","RST_PCIE_SLOT3_N","", + "","PRSNT_NIC0_N","","" /*V0-V7*/ "FM_RESBTN_SLOT5_BMC_N","FM_RESBTN_SLOT6_BMC_N", "FM_RESBTN_SLOT7_BMC_N","FM_RESBTN_SLOT8_BMC_N", "","","","", -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:35 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:35 +0800 Subject: [PATCH linux dev-6.6 v1 12/14] ARM: dts: aspeed: yosemite4: add mctp config for NIC In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-13-Delphine_CC_Chiu@wiwynn.com> add mctp config for NIC Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 073f27f1e35f..c8e3a85b7a11 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1273,40 +1273,64 @@ imux24: i2c at 0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; imux25: i2c at 1 { #address-cells = <1>; #size-cells = <0>; reg = <1>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; imux26: i2c at 2 { #address-cells = <1>; #size-cells = <0>; reg = <2>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; imux27: i2c at 3 { #address-cells = <1>; #size-cells = <0>; reg = <3>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 14:13:36 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 11:13:36 +0800 Subject: [PATCH linux dev-6.6 v1 13/14] ARM: dts: aspeed: yosemite4: support mux to cpld In-Reply-To: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211031337.4165619-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211031337.4165619-14-Delphine_CC_Chiu@wiwynn.com> Mux pca9544 to cpld was added on EVT HW schematic design, so add dts setting for devices behind mux pca9544 to cpld Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 64 ++++++++++++++----- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index c8e3a85b7a11..fdc33bffd467 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -36,6 +36,10 @@ aliases { i2c31 = &imux31; i2c32 = &imux32; i2c33 = &imux33; + i2c34 = &imux34; + i2c35 = &imux35; + i2c36 = &imux36; + i2c37 = &imux37; }; chosen { @@ -951,24 +955,54 @@ &i2c12 { status = "okay"; bus-frequency = <400000>; - temperature-sensor at 48 { - compatible = "ti,tmp75"; - reg = <0x48>; - }; + i2c-mux at 70 { + compatible = "nxp,pca9544"; + i2c-mux-idle-disconnect; + reg = <0x70>; - eeprom at 50 { - compatible = "atmel,24c128"; - reg = <0x50>; - }; + imux34: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; - eeprom at 54 { - compatible = "atmel,24c64"; - reg = <0x54>; - }; + temperature-sensor at 48 { + compatible = "ti,tmp75"; + reg = <0x48>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; - rtc at 6f { - compatible = "nuvoton,nct3018y"; - reg = <0x6f>; + eeprom at 54 { + compatible = "atmel,24c64"; + reg = <0x54>; + }; + + rtc at 6f { + compatible = "nuvoton,nct3018y"; + reg = <0x6f>; + }; + }; + + imux35: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + + imux36: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + }; + + imux37: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + }; }; }; -- 2.25.1 From potin.lai.pt at gmail.com Mon Dec 11 14:13:18 2023 From: potin.lai.pt at gmail.com (Potin Lai) Date: Mon, 11 Dec 2023 11:13:18 +0800 Subject: [PATCH linux dev-6.6 1/2] dt-bindings: iio: Add MCP9600 thermocouple EMF converter Message-ID: <20231211031319.3810692-1-potin.lai.pt@gmail.com> From: Andrew Hepp Add support for the MCP9600 thermocouple electromotive force converter. The sensor has integrated cold junction compensation and a typical accuracy of 0.5 degrees Celsius. The driver supports a resolution of 0.0625 degrees Celsius. Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf Signed-off-by: Andrew Hepp Reviewed-by: Krzysztof Kozlowski --- .../iio/temperature/microchip,mcp9600.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml diff --git a/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml new file mode 100644 index 0000000000000..d2cafa38a5442 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/microchip,mcp9600.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/microchip,mcp9600.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip MCP9600 thermocouple EMF converter + +maintainers: + - Andrew Hepp + +description: + https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf + +properties: + compatible: + const: microchip,mcp9600 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 6 + + interrupt-names: + minItems: 1 + maxItems: 6 + items: + enum: + - open-circuit + - short-circuit + - alert1 + - alert2 + - alert3 + - alert4 + + thermocouple-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Type of thermocouple (THERMOCOUPLE_TYPE_K if omitted). + Use defines in dt-bindings/iio/temperature/thermocouple.h. + Supported types are B, E, J, K, N, R, S, T. + + vdd-supply: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + temperature-sensor at 60 { + compatible = "microchip,mcp9600"; + reg = <0x60>; + interrupt-parent = <&gpio>; + interrupts = <25 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "open-circuit"; + thermocouple-type = ; + vdd-supply = <&vdd>; + }; + }; -- 2.31.1 From potin.lai.pt at gmail.com Mon Dec 11 14:13:19 2023 From: potin.lai.pt at gmail.com (Potin Lai) Date: Mon, 11 Dec 2023 11:13:19 +0800 Subject: [PATCH linux dev-6.6 2/2] iio: temperature: Add MCP9600 thermocouple EMF converter In-Reply-To: <20231211031319.3810692-1-potin.lai.pt@gmail.com> References: <20231211031319.3810692-1-potin.lai.pt@gmail.com> Message-ID: <20231211031319.3810692-2-potin.lai.pt@gmail.com> From: Andrew Hepp Add support for the MCP9600 thermocouple electromotive force converter. The sensor has integrated cold junction compensation and a typical accuracy of 0.5 degrees Celsius. The driver supports a resolution of 0.0625 degrees Celsius. Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/MCP960X-Data-Sheet-20005426.pdf Signed-off-by: Andrew Hepp --- drivers/iio/temperature/Kconfig | 10 +++ drivers/iio/temperature/Makefile | 1 + drivers/iio/temperature/mcp9600.c | 139 ++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 drivers/iio/temperature/mcp9600.c diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig index ed384f33e0c76..ea2ce364b2e91 100644 --- a/drivers/iio/temperature/Kconfig +++ b/drivers/iio/temperature/Kconfig @@ -158,4 +158,14 @@ config MAX31865 This driver can also be build as a module. If so, the module will be called max31865. +config MCP9600 + tristate "MCP9600 thermocouple EMF converter" + depends on I2C + help + If you say yes here you get support for MCP9600 + thermocouple EMF converter connected via I2C. + + This driver can also be built as a module. If so, the module + will be called mcp9600. + endmenu diff --git a/drivers/iio/temperature/Makefile b/drivers/iio/temperature/Makefile index dfec8c6d30193..9330d4a39598d 100644 --- a/drivers/iio/temperature/Makefile +++ b/drivers/iio/temperature/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_MAXIM_THERMOCOUPLE) += maxim_thermocouple.o obj-$(CONFIG_MAX30208) += max30208.o obj-$(CONFIG_MAX31856) += max31856.o obj-$(CONFIG_MAX31865) += max31865.o +obj-$(CONFIG_MCP9600) += mcp9600.o obj-$(CONFIG_MLX90614) += mlx90614.o obj-$(CONFIG_MLX90632) += mlx90632.o obj-$(CONFIG_TMP006) += tmp006.o diff --git a/drivers/iio/temperature/mcp9600.c b/drivers/iio/temperature/mcp9600.c new file mode 100644 index 0000000000000..46845804292bf --- /dev/null +++ b/drivers/iio/temperature/mcp9600.c @@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * mcp9600.c - Support for Microchip MCP9600 thermocouple EMF converter + * + * Copyright (c) 2022 Andrew Hepp + * Author: + */ + +#include +#include +#include +#include +#include + +#include + +/* MCP9600 registers */ +#define MCP9600_HOT_JUNCTION 0x0 +#define MCP9600_COLD_JUNCTION 0x2 +#define MCP9600_DEVICE_ID 0x20 + +/* MCP9600 device id value */ +#define MCP9600_DEVICE_ID_MCP9600 0x40 + +static const struct iio_chan_spec mcp9600_channels[] = { + { + .type = IIO_TEMP, + .address = MCP9600_HOT_JUNCTION, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type = IIO_TEMP, + .address = MCP9600_COLD_JUNCTION, + .channel2 = IIO_MOD_TEMP_AMBIENT, + .modified = 1, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + }, +}; + +struct mcp9600_data { + struct i2c_client *client; +}; + +static int mcp9600_read(struct mcp9600_data *data, + struct iio_chan_spec const *chan, int *val) +{ + int ret; + + ret = i2c_smbus_read_word_swapped(data->client, chan->address); + + if (ret < 0) + return ret; + *val = ret; + + return 0; +} + +static int mcp9600_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct mcp9600_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = mcp9600_read(data, chan, val); + if (ret) + return ret; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 62; + *val2 = 500000; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } +} + +static const struct iio_info mcp9600_info = { + .read_raw = mcp9600_read_raw, +}; + +static int mcp9600_probe(struct i2c_client *client) +{ + struct iio_dev *indio_dev; + struct mcp9600_data *data; + int ret; + + ret = i2c_smbus_read_byte_data(client, MCP9600_DEVICE_ID); + if (ret < 0) + return dev_err_probe(&client->dev, ret, "Failed to read device ID\n"); + if (ret != MCP9600_DEVICE_ID_MCP9600) + dev_warn(&client->dev, "Expected ID %x, got %x\n", + MCP9600_DEVICE_ID_MCP9600, ret); + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + data->client = client; + + indio_dev->info = &mcp9600_info; + indio_dev->name = "mcp9600"; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = mcp9600_channels; + indio_dev->num_channels = ARRAY_SIZE(mcp9600_channels); + + return devm_iio_device_register(&client->dev, indio_dev); +} + +static const struct i2c_device_id mcp9600_id[] = { + { "mcp9600" }, + {} +}; +MODULE_DEVICE_TABLE(i2c, mcp9600_id); + +static const struct of_device_id mcp9600_of_match[] = { + { .compatible = "microchip,mcp9600" }, + {} +}; +MODULE_DEVICE_TABLE(of, mcp9600_of_match); + +static struct i2c_driver mcp9600_driver = { + .driver = { + .name = "mcp9600", + .of_match_table = mcp9600_of_match, + }, + .probe = mcp9600_probe, + .id_table = mcp9600_id +}; +module_i2c_driver(mcp9600_driver); + +MODULE_AUTHOR("Andrew Hepp "); +MODULE_DESCRIPTION("Microchip MCP9600 thermocouple EMF converter driver"); +MODULE_LICENSE("GPL"); -- 2.31.1 From quan at os.amperecomputing.com Mon Dec 11 15:06:12 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 11:06:12 +0700 Subject: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-3-quan@os.amperecomputing.com> Message-ID: <79d8377f-b443-47cd-831c-4f27a4f59572@os.amperecomputing.com> On 08/12/2023 11:00, Andrew Jeffery wrote: > On Fri, 2023-12-08 at 10:31 +0700, Quan Nguyen wrote: >> Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in >> interrupt handler") acknowledges most interrupts early before the slave >> irq handler is executed, except for the "Receive Done Interrupt status" >> which is acknowledged late in the interrupt. >> However, it has been observed that the early acknowledgment of "Transmit >> Done Interrupt Status" (with ACK or NACK) often causes the interrupt to >> be raised in READ REQUEST state, that shows the >> "Unexpected ACK on read request." complaint messages. >> >> Assuming that the "Transmit Done" interrupt should only be acknowledged >> once it is truly processed, this commit fixes that issue by acknowledging >> interrupts for both ACK and NACK cases late in the interrupt handler. >> >> Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") >> Signed-off-by: Quan Nguyen >> --- >> v3: >> + Fix the unconditinal write when ack the irqs [Andrew] >> + Refactor the code to enhance code readability [Quan] >> + Fix grammar in commit message [Quan] >> >> v2: >> + Split to separate series [Joel] >> + Added the Fixes line [Joel] >> + Fixed multiline comment [Joel] >> + Refactor irq clearing code [Joel, Guenter] >> + Revised commit message [Joel] >> + Revised commit message [Quan] >> + About a note to remind why the readl() should immediately follow the >> writel() to fix the race condition when clearing irq status from commit >> c926c87b8e36 ("i2c: aspeed: Avoid i2c interrupt status clear race >> condition"), I think it looks straight forward in this patch and decided >> not to add that note. [Joel] >> >> v1: >> + First introduced in >> https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ >> --- >> drivers/i2c/busses/i2c-aspeed.c | 21 +++++++++++++-------- >> 1 file changed, 13 insertions(+), 8 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c >> index 1c2a4f4c4e1b..967a26dd4ffa 100644 >> --- a/drivers/i2c/busses/i2c-aspeed.c >> +++ b/drivers/i2c/busses/i2c-aspeed.c >> @@ -617,13 +617,19 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) >> static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) >> { >> struct aspeed_i2c_bus *bus = dev_id; >> - u32 irq_received, irq_remaining, irq_handled; >> + u32 irq_received, irq_remaining, irq_handled, irq_ack_last; > > `irq_ack_last` might be better as a macro, but you're probably saved by > the optimiser anyway. If there's another reason to do a v4 or others > are unhappy with it then consider fixing it, otherwise: > > Reviewed-by: Andrew Jeffery > I'll send out the v4 to use the defined macro instead as below: Thanks Andi, for the suggestion on the macro name. diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 5511fd46a65e..0f67218cf04a 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -93,6 +93,10 @@ ASPEED_I2CD_INTR_RX_DONE | \ ASPEED_I2CD_INTR_TX_NAK | \ ASPEED_I2CD_INTR_TX_ACK) +#define ASPEED_I2CD_INTR_ACK_RX_TX \ + (ASPEED_I2CD_INTR_RX_DONE | \ + ASPEED_I2CD_INTR_TX_ACK | \ + ASPEED_I2CD_INTR_TX_NAK) Thanks for the review, - Quan From quan at os.amperecomputing.com Mon Dec 11 15:06:27 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 11:06:27 +0700 Subject: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231208033142.1673232-3-quan@os.amperecomputing.com> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-3-quan@os.amperecomputing.com> Message-ID: On 08/12/2023 10:31, Quan Nguyen wrote: > Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in > interrupt handler") acknowledges most interrupts early before the slave > irq handler is executed, except for the "Receive Done Interrupt status" > which is acknowledged late in the interrupt. > However, it has been observed that the early acknowledgment of "Transmit > Done Interrupt Status" (with ACK or NACK) often causes the interrupt to > be raised in READ REQUEST state, that shows the > "Unexpected ACK on read request." complaint messages. > > Assuming that the "Transmit Done" interrupt should only be acknowledged > once it is truly processed, this commit fixes that issue by acknowledging > interrupts for both ACK and NACK cases late in the interrupt handler. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > Signed-off-by: Quan Nguyen > --- > v3: > + Fix the unconditinal write when ack the irqs [Andrew] > + Refactor the code to enhance code readability [Quan] > + Fix grammar in commit message [Quan] > > v2: > + Split to separate series [Joel] > + Added the Fixes line [Joel] > + Fixed multiline comment [Joel] > + Refactor irq clearing code [Joel, Guenter] > + Revised commit message [Joel] > + Revised commit message [Quan] > + About a note to remind why the readl() should immediately follow the > writel() to fix the race condition when clearing irq status from commit > c926c87b8e36 ("i2c: aspeed: Avoid i2c interrupt status clear race > condition"), I think it looks straight forward in this patch and decided > not to add that note. [Joel] > > v1: > + First introduced in > https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ > --- > drivers/i2c/busses/i2c-aspeed.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c > index 1c2a4f4c4e1b..967a26dd4ffa 100644 > --- a/drivers/i2c/busses/i2c-aspeed.c > +++ b/drivers/i2c/busses/i2c-aspeed.c > @@ -617,13 +617,19 @@ static u32 aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus, u32 irq_status) > static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) > { > struct aspeed_i2c_bus *bus = dev_id; > - u32 irq_received, irq_remaining, irq_handled; > + u32 irq_received, irq_remaining, irq_handled, irq_ack_last; > > spin_lock(&bus->lock); > irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); > - /* Ack all interrupts except for Rx done */ > - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, > - bus->base + ASPEED_I2C_INTR_STS_REG); > + > + /* > + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would indicate HW to > + * start receiving or sending new data, and this may cause a race condition > + * as the irq handler has not yet handled these irqs but is being acked. > + * Let's ack them late at the end of the irq handler when those are truly processed. > + */ > + irq_ack_last = ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK; > + writel(irq_received & ~irq_ack_last, bus->base + ASPEED_I2C_INTR_STS_REG); As there will be v4, I'd like to improve this line of code a bit. During debug, there are significant number of times when the irq_received has the value of 0x00000004 (INTR_RX_DONE) or 0x00000001 (INTR_TX_ACK). This makes the "irq_received & ~irq_ack_last" turn out to be 0. AFAIK, it does not make sense to keep repeatedly writing the 0 to the HW then try to re-read it with readl() every time. I'd like to change this HW access conditionally to avoid those unnecessary access. The change would looks like below: diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 5511fd46a65e..0f67218cf04a 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -93,6 +93,10 @@ ASPEED_I2CD_INTR_RX_DONE | \ ASPEED_I2CD_INTR_TX_NAK | \ ASPEED_I2CD_INTR_TX_ACK) +#define ASPEED_I2CD_INTR_ACK_RX_TX \ + (ASPEED_I2CD_INTR_RX_DONE | \ + ASPEED_I2CD_INTR_TX_ACK | \ + ASPEED_I2CD_INTR_TX_NAK) /* 0x14 : I2CD Command/Status Register */ #define ASPEED_I2CD_SCL_LINE_STS BIT(18) @@ -622,10 +626,19 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) spin_lock(&bus->lock); irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); - /* Ack all interrupts except for Rx done */ - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, - bus->base + ASPEED_I2C_INTR_STS_REG); - readl(bus->base + ASPEED_I2C_INTR_STS_REG); + + /* + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would + ... + */ + if (irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX) { + writel(irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX, + bus->base + ASPEED_I2C_INTR_STS_REG); + readl(bus->base + ASPEED_I2C_INTR_STS_REG); + } + irq_received &= ASPEED_I2CD_INTR_RECV_MASK; irq_remaining = irq_received; Thanks, - Quan From quan at os.amperecomputing.com Mon Dec 11 15:06:45 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 11:06:45 +0700 Subject: [PATCH v3 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231209204455.jxize3muvx7hhpos@zenone.zhora.eu> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-3-quan@os.amperecomputing.com> <20231209204455.jxize3muvx7hhpos@zenone.zhora.eu> Message-ID: <8822a211-678f-49e5-8e6b-50b46dfc61b3@os.amperecomputing.com> On 10/12/2023 03:44, Andi Shyti wrote: > Hi Quan, > > [...] > >> - /* Ack all interrupts except for Rx done */ >> - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, >> - bus->base + ASPEED_I2C_INTR_STS_REG); >> + >> + /* >> + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would indicate HW to >> + * start receiving or sending new data, and this may cause a race condition >> + * as the irq handler has not yet handled these irqs but is being acked. >> + * Let's ack them late at the end of the irq handler when those are truly processed. >> + */ >> + irq_ack_last = ASPEED_I2CD_INTR_RX_DONE | ASPEED_I2CD_INTR_TX_ACK | ASPEED_I2CD_INTR_TX_NAK; >> + writel(irq_received & ~irq_ack_last, bus->base + ASPEED_I2C_INTR_STS_REG); > > I like Andrews suggestion of having irq_ack_last as a define that > is already negated, instead of negating it in the writel, which > makes it a bit difficult to read. > Yes, but the it still need to negate again when do the write to late ack them later in the end of irq handler. So I'll keep the define as below in my v4: +#define ASPEED_I2CD_INTR_ACK_RX_TX \ + (ASPEED_I2CD_INTR_RX_DONE | \ + ASPEED_I2CD_INTR_TX_ACK | \ + ASPEED_I2CD_INTR_TX_NAK) The early ack will look like this: + writel(irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX, + bus->base + ASPEED_I2C_INTR_STS_REG); + readl(bus->base + ASPEED_I2C_INTR_STS_REG); And the late ack: - /* Ack Rx done */ - if (irq_received & ASPEED_I2CD_INTR_RX_DONE) { - writel(ASPEED_I2CD_INTR_RX_DONE, + if (irq_received & ASPEED_I2CD_INTR_ACK_RX_TX) { + writel(irq_received & ASPEED_I2CD_INTR_ACK_RX_TX, bus->base + ASPEED_I2C_INTR_STS_REG); readl(bus->base + ASPEED_I2C_INTR_STS_REG); } > Besides, ack_last, as a name is not very meaningful, I'd rather > call it irq_ack_rx_tx (or something similar). > > But I'm not going to block it for this, up to you if you want to > send a new version. > > Reviewed-by: Andi Shyti > Thanks, Andi for the comments. I will send out v4 to address those. - Quan From quan at os.amperecomputing.com Mon Dec 11 15:08:52 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 11:08:52 +0700 Subject: [PATCH v3 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <79ce9162faeb113ecb13efeb58d95f8a71e1a060.camel@codeconstruct.com.au> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-2-quan@os.amperecomputing.com> <79ce9162faeb113ecb13efeb58d95f8a71e1a060.camel@codeconstruct.com.au> Message-ID: <43c99449-8a4b-4db5-8b1e-bc7ae920db76@os.amperecomputing.com> On 08/12/2023 10:56, Andrew Jeffery wrote: > On Fri, 2023-12-08 at 10:31 +0700, Quan Nguyen wrote: >> Some masters may drive the transfers with low enough latency between >> the nak/stop phase of the current command and the start/address phase >> of the following command that the interrupts are coalesced by the >> time we process them. >> Handle the stop conditions before processing SLAVE_MATCH to fix the >> complaints that sometimes occur below. >> >> "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected >> 0x00000086, but was 0x00000084" >> >> Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") >> Signed-off-by: Quan Nguyen >> --- >> v3: >> + Change to handle the coalesced stop condition with the start >> conditions [Andrew] >> + Revised commit message [Quan] >> >> v2: >> + Split to separate series [Joel] >> + Added the Fixes line [Joel] >> + Revised commit message [Quan] >> >> v1: >> + First introduced in >> https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ >> --- >> drivers/i2c/busses/i2c-aspeed.c | 47 ++++++++++++++++++++++----------- >> 1 file changed, 31 insertions(+), 16 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c >> index 28e2a5fc4528..1c2a4f4c4e1b 100644 >> --- a/drivers/i2c/busses/i2c-aspeed.c >> +++ b/drivers/i2c/busses/i2c-aspeed.c >> @@ -249,18 +249,45 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) >> if (!slave) >> return 0; >> >> - command = readl(bus->base + ASPEED_I2C_CMD_REG); >> + /* >> + * Handle stop conditions early, prior to SLAVE_MATCH. Some masters may drive >> + * transfers with low enough latency between the nak/stop phase of the current >> + * command and the start/address phase of the following command that the >> + * interrupts are coalesced by the time we process them. >> + */ >> + if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { >> + irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; >> + bus->slave_state = ASPEED_I2C_SLAVE_STOP; >> + } >> >> - /* Slave was requested, restart state machine. */ >> + if (irq_status & ASPEED_I2CD_INTR_TX_NAK && >> + bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { >> + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; >> + bus->slave_state = ASPEED_I2C_SLAVE_STOP; >> + } >> + >> + /* Propagate any stop conditions to the slave implementation. */ >> + if (bus->slave_state == ASPEED_I2C_SLAVE_STOP) { >> + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); >> + bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; >> + } >> + /* > > If there's a reason to do a v4 then an extra empty line above the > comment would be nice. But let's not get hung up on that if everyone > else is happy. > > Thanks for the fixes! > > Reviewed-by: Andrew Jeffery > Thanks Andrew, I'll add your Reviewed-by in my v4 with that extra empty lime before the comment. Thanks for the review - Quan From quan at os.amperecomputing.com Mon Dec 11 15:09:08 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 11:09:08 +0700 Subject: [PATCH v3 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231209202810.r7kkz2hlaonyibha@zenone.zhora.eu> References: <20231208033142.1673232-1-quan@os.amperecomputing.com> <20231208033142.1673232-2-quan@os.amperecomputing.com> <20231209202810.r7kkz2hlaonyibha@zenone.zhora.eu> Message-ID: On 10/12/2023 03:28, Andi Shyti wrote: > Hi Quan, > > On Fri, Dec 08, 2023 at 10:31:41AM +0700, Quan Nguyen wrote: >> Some masters may drive the transfers with low enough latency between >> the nak/stop phase of the current command and the start/address phase >> of the following command that the interrupts are coalesced by the >> time we process them. >> Handle the stop conditions before processing SLAVE_MATCH to fix the >> complaints that sometimes occur below. >> >> "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected >> 0x00000086, but was 0x00000084" >> >> Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") >> Signed-off-by: Quan Nguyen > > Reviewed-by: Andi Shyti > Thanks Andi, I'll add your Reviewed-by in v4 Thanks, - Quan From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:24 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:24 +0800 Subject: [PATCH linux dev-6.6 v2 00/14] Add i2c-mux and eeprom devices for Meta Yosemite 4 Message-ID: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Changelog: - v2 - Correct patch for revising gpio name - v1 - Add gpio and eeprom behind i2c-mux - Remove redundant idle-state setting for i2c-mux - Enable adc 15, wdt2,spi gpio for yosemite4 use - Revise quad mode to dual mode to avoid WP pin influnece the SPI - Revise power sensor adm1281 for yosemite4 schematic change - Add gpio pca9506 I/O expander for yosemite4 use - remove space for adm1272 compatible - enable interrupt setting for pca9555 - add eeprom for yosemite4 medusa board/BSM use - remove temperature sensor for yosemite4 schematic change - add power sensor for power module reading - Revise adc128d818 adc mode for yosemite4 schematic change - Revise ina233 for yosemite4 schematic change - Remove idle state setting for yosemite4 NIC connection - Initialize bmc gpio state - Revise mx31790 fan tach config - Add mctp config for NIC - Support mux to cpld - Revise gpio name Delphine CC Chiu (14): ARM: dts: aspeed: yosemite4: Revise i2c-mux devices ARM: dts: aspeed: yosemite4: Enable adc15 ARM: dts: aspeed: yosemite4: Enable spi-gpio setting ARM: dts: aspeed: yosemite4: Enable watchdog2 ARM: dts: aspeed: yosemite4: Revise quad mode to dual mode ARM: dts: aspeed: yosemite4: Revise power sensor adm1281 for schematic change ARM: dts: aspeed: yosemite4: Add gpio pca9506 ARM: dts: aspeed: yosemite4: Revise i2c11 and i2c12 schematic change ARM: dts: aspeed: yosemite4: Revise i2c14 and i2c15 schematic change ARM: dts: aspeed: yosemite4: Initialize bmc gpio state ARM: dts: aspeed: yosemite4: Revise mx31790 fan tach config ARM: dts: aspeed: yosemite4: add mctp config for NIC ARM: dts: aspeed: yosemite4: support mux to cpld ARM: dts: aspeed: yosemite4: Revise gpio name .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 1215 +++++++++++++++-- 1 file changed, 1091 insertions(+), 124 deletions(-) -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:25 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:25 +0800 Subject: [PATCH linux dev-6.6 v2 01/14] ARM: dts: aspeed: yosemite4: Revise i2c-mux devices In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-2-Delphine_CC_Chiu@wiwynn.com> Revise Yosemite 4 devicetree for devices behind i2c-mux - Add gpio and eeprom behind i2c-mux - Remove redundant idle-state setting for i2c-mux Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 381 ++++++++++++++++-- 1 file changed, 347 insertions(+), 34 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 64075cc41d92..a5b4585e81e6 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -17,6 +17,25 @@ aliases { serial6 = &uart7; serial7 = &uart8; serial8 = &uart9; + + i2c16 = &imux16; + i2c17 = &imux17; + i2c18 = &imux18; + i2c19 = &imux19; + i2c20 = &imux20; + i2c21 = &imux21; + i2c22 = &imux22; + i2c23 = &imux23; + i2c24 = &imux24; + i2c25 = &imux25; + i2c26 = &imux26; + i2c27 = &imux27; + i2c28 = &imux28; + i2c29 = &imux29; + i2c30 = &imux30; + i2c31 = &imux31; + i2c32 = &imux32; + i2c33 = &imux33; }; chosen { @@ -259,9 +278,109 @@ &i2c8 { bus-frequency = <400000>; i2c-mux at 70 { compatible = "nxp,pca9544"; - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x70>; + + imux16: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux17: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux18: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux19: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; }; }; @@ -270,15 +389,174 @@ &i2c9 { bus-frequency = <400000>; i2c-mux at 71 { compatible = "nxp,pca9544"; - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x71>; + + imux20: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux21: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux22: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; + + imux23: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + + gpio at 49 { + compatible = "nxp,pca9537"; + reg = <0x49>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c128"; + reg = <0x51>; + }; + + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; + }; + }; }; }; &i2c10 { status = "okay"; bus-frequency = <400000>; + i2c-mux at 74 { + compatible = "nxp,pca9544"; + i2c-mux-idle-disconnect; + reg = <0x74>; + + imux28: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 24 { + compatible = "nxp,pca9506"; + reg = <0x24>; + gpio-controller; + #gpio-cells = <2>; + gpio-line-names = + "","","","", + "NIC0_MAIN_PWR_EN","NIC1_MAIN_PWR_EN", + "NIC2_MAIN_PWR_EN","NIC3_MAIN_PWR_EN", + "","","","","","","","", + "","","","","","","","", + "","","","","","","",""; + }; + }; + + imux29: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; }; &i2c11 { @@ -433,16 +711,14 @@ eeprom at 51 { reg = <0x51>; }; - i2c-mux at 71 { - compatible = "nxp,pca9846"; + i2c-mux at 74 { + compatible = "nxp,pca9546"; #address-cells = <1>; #size-cells = <0>; - - idle-state = <0>; i2c-mux-idle-disconnect; - reg = <0x71>; + reg = <0x74>; - i2c at 0 { + imux30: i2c at 0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; @@ -450,26 +726,26 @@ i2c at 0 { adc at 1f { compatible = "ti,adc128d818"; reg = <0x1f>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; pwm at 20{ - compatible = "max31790"; + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; reg = <0x20>; - #address-cells = <1>; - #size-cells = <0>; }; gpio at 22{ compatible = "ti,tca6424"; reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; }; - pwm at 23{ - compatible = "max31790"; - reg = <0x23>; - #address-cells = <1>; - #size-cells = <0>; + pwm at 2f{ + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; + reg = <0x2f>; }; adc at 33 { @@ -492,34 +768,34 @@ gpio at 61 { }; }; - i2c at 1 { + imux31: i2c at 1 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <1>; adc at 1f { compatible = "ti,adc128d818"; reg = <0x1f>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; pwm at 20{ - compatible = "max31790"; + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; reg = <0x20>; - #address-cells = <1>; - #size-cells = <0>; }; gpio at 22{ compatible = "ti,tca6424"; reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; }; - pwm at 23{ - compatible = "max31790"; - reg = <0x23>; - #address-cells = <1>; - #size-cells = <0>; + pwm at 2f{ + compatible = "maxim,max31790"; + pwm-as-tach = <4 5>; + reg = <0x2f>; }; adc at 33 { @@ -547,12 +823,10 @@ i2c-mux at 73 { compatible = "nxp,pca9544"; #address-cells = <1>; #size-cells = <0>; - - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x73>; - i2c at 0 { + imux32: i2c at 0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; @@ -563,10 +837,10 @@ adc at 35 { }; }; - i2c at 1 { + imux33: i2c at 1 { #address-cells = <1>; #size-cells = <0>; - reg = <0>; + reg = <1>; adc at 35 { compatible = "maxim,max11617"; @@ -589,9 +863,48 @@ mctp at 10 { i2c-mux at 72 { compatible = "nxp,pca9544"; - idle-state = <0>; i2c-mux-idle-disconnect; reg = <0x72>; + + imux24: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; + + imux25: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; + + imux26: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; + + imux27: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + temperature-sensor at 1f { + compatible = "ti,tmp421"; + reg = <0x1f>; + }; + }; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:26 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:26 +0800 Subject: [PATCH linux dev-6.6 v2 02/14] ARM: dts: aspeed: yosemite4: Enable adc15 In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-3-Delphine_CC_Chiu@wiwynn.com> Enable Yosemite 4 adc15 config Signed-off-by: Delphine CC Chiu --- arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index a5b4585e81e6..c32736fbaf70 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -51,7 +51,7 @@ iio-hwmon { compatible = "iio-hwmon"; io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, <&adc0 7>, - <&adc1 0>, <&adc1 1>; + <&adc1 0>, <&adc1 1>, <&adc1 7>; }; }; @@ -920,10 +920,10 @@ &pinctrl_adc4_default &pinctrl_adc5_default &adc1 { ref_voltage = <2500>; status = "okay"; - pinctrl-0 = <&pinctrl_adc8_default &pinctrl_adc9_default>; + pinctrl-0 = <&pinctrl_adc8_default &pinctrl_adc9_default + &pinctrl_adc15_default>; }; - &ehci0 { status = "okay"; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:28 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:28 +0800 Subject: [PATCH linux dev-6.6 v2 04/14] ARM: dts: aspeed: yosemite4: Enable watchdog2 In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-5-Delphine_CC_Chiu@wiwynn.com> enable watchdog2 setting Signed-off-by: Delphine CC Chiu --- arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 0449a7e36ff6..0e9095c83a59 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -120,6 +120,13 @@ &wdt1 { aspeed,ext-pulse-duration = <256>; }; +&wdt2 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_wdtrst2_default>; + aspeed,reset-type = "system"; +}; + &mac2 { status = "okay"; pinctrl-names = "default"; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:29 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:29 +0800 Subject: [PATCH linux dev-6.6 v2 05/14] ARM: dts: aspeed: yosemite4: Revise quad mode to dual mode In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-6-Delphine_CC_Chiu@wiwynn.com> Revise quad mode to dual mode to avoid WP pin influnece the SPI Signed-off-by: Delphine CC Chiu --- .../arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 0e9095c83a59..7fe80ad271aa 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -149,15 +149,17 @@ flash at 0 { status = "okay"; m25p,fast-read; label = "bmc"; - spi-rx-bus-width = <4>; + spi-tx-bus-width = <2>; + spi-rx-bus-width = <2>; spi-max-frequency = <50000000>; -#include "openbmc-flash-layout-64.dtsi" +#include "openbmc-flash-layout-128.dtsi" }; flash at 1 { status = "okay"; m25p,fast-read; label = "bmc2"; - spi-rx-bus-width = <4>; + spi-tx-bus-width = <2>; + spi-rx-bus-width = <2>; spi-max-frequency = <50000000>; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:27 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:27 +0800 Subject: [PATCH linux dev-6.6 v2 03/14] ARM: dts: aspeed: yosemite4: Enable spi-gpio setting In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-4-Delphine_CC_Chiu@wiwynn.com> enable spi-gpio setting for spi flash Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index c32736fbaf70..0449a7e36ff6 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -53,6 +53,24 @@ iio-hwmon { <&adc0 4>, <&adc0 5>, <&adc0 6>, <&adc0 7>, <&adc1 0>, <&adc1 1>, <&adc1 7>; }; + + spi_gpio: spi-gpio { + compatible = "spi-gpio"; + #address-cells = <1>; + #size-cells = <0>; + + gpio-sck = <&gpio0 ASPEED_GPIO(X, 3) GPIO_ACTIVE_HIGH>; + gpio-mosi = <&gpio0 ASPEED_GPIO(X, 4) GPIO_ACTIVE_HIGH>; + gpio-miso = <&gpio0 ASPEED_GPIO(X, 5) GPIO_ACTIVE_HIGH>; + num-chipselects = <1>; + cs-gpios = <&gpio0 ASPEED_GPIO(X, 0) GPIO_ACTIVE_LOW>; + + tpmdev at 0 { + compatible = "tcg,tpm_tis-spi"; + spi-max-frequency = <33000000>; + reg = <0>; + }; + }; }; &uart1 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:31 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:31 +0800 Subject: [PATCH linux dev-6.6 v2 07/14] ARM: dts: aspeed: yosemite4: Add gpio pca9506 In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-8-Delphine_CC_Chiu@wiwynn.com> Add gpio pca9506 I/O expander for yv4 use Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 7f0134fcee57..da413325ce30 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -175,6 +175,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -193,6 +221,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -211,6 +267,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -229,6 +313,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -247,6 +359,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -265,6 +405,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -283,6 +451,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -301,6 +497,34 @@ mctp at 10 { reg = <(0x10 | I2C_OWN_SLAVE_ADDRESS)>; }; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; + power-sensor at 40 { compatible = "adi,adm1281"; reg = <0x40>; @@ -683,6 +907,33 @@ rtc at 6f { &i2c13 { status = "okay"; bus-frequency = <400000>; + gpio at 20 { + compatible = "nxp,pca9506"; + reg = <0x20>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 21 { + compatible = "nxp,pca9506"; + reg = <0x21>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 22 { + compatible = "nxp,pca9506"; + reg = <0x22>; + gpio-controller; + #gpio-cells = <2>; + }; + + gpio at 23 { + compatible = "nxp,pca9506"; + reg = <0x23>; + gpio-controller; + #gpio-cells = <2>; + }; }; &i2c14 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:30 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:30 +0800 Subject: [PATCH linux dev-6.6 v2 06/14] ARM: dts: aspeed: yosemite4: Revise power sensor adm1281 for schematic change In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-7-Delphine_CC_Chiu@wiwynn.com> Revise power sensor adm1281 for yosemite4 schematic change Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 7fe80ad271aa..7f0134fcee57 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -176,8 +176,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -193,8 +194,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -210,8 +212,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -227,8 +230,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -244,8 +248,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -261,8 +266,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -278,8 +284,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; @@ -295,8 +302,9 @@ mctp at 10 { }; power-sensor at 40 { - compatible = "adi,adm1278"; + compatible = "adi,adm1281"; reg = <0x40>; + shunt-resistor-micro-ohms = <500>; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:32 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:32 +0800 Subject: [PATCH linux dev-6.6 v2 08/14] ARM: dts: aspeed: yosemite4: Revise i2c11 and i2c12 schematic change In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-9-Delphine_CC_Chiu@wiwynn.com> Revise i2c11 and i2c12 schematic change: - remove space for adm1272 compatible - enable interrupt setting for pca9555 - add eeprom for yosemite4 medusa board/BSM use - remove temperature sensor for yosemite4 schematic change - add power sensor for power module reading Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 118 ++++++++++++++---- 1 file changed, 93 insertions(+), 25 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index da413325ce30..ccb5ecd8d9a6 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -821,41 +821,94 @@ imux29: i2c at 1 { &i2c11 { status = "okay"; power-sensor at 10 { - compatible = "adi, adm1272"; + compatible = "adi,adm1272"; reg = <0x10>; }; power-sensor at 12 { - compatible = "adi, adm1272"; + compatible = "adi,adm1272"; reg = <0x12>; }; - gpio at 20 { + gpio_ext1: pca9555 at 20 { compatible = "nxp,pca9555"; - reg = <0x20>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; - }; - - gpio at 21 { + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "P48V_OCP_GPIO1","P48V_OCP_GPIO2", + "P48V_OCP_GPIO3","FAN_BOARD_0_REVISION_0_R", + "FAN_BOARD_0_REVISION_1_R","FAN_BOARD_1_REVISION_0_R", + "FAN_BOARD_1_REVISION_1_R","RST_MUX_R_N", + "RST_LED_CONTROL_FAN_BOARD_0_N","RST_LED_CONTROL_FAN_BOARD_1_N", + "RST_IOEXP_FAN_BOARD_0_N","RST_IOEXP_FAN_BOARD_1_N", + "PWRGD_LOAD_SWITCH_FAN_BOARD_0_R","PWRGD_LOAD_SWITCH_FAN_BOARD_1_R", + "",""; + }; + + gpio_ext2: pca9555 at 21 { compatible = "nxp,pca9555"; - reg = <0x21>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; - }; - - gpio at 22 { + reg = <0x21>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "DELTA_MODULE_TYPE","VSENSE_ERR_VDROP_R", + "EN_P48V_AUX_0","EN_P48V_AUX_1", + "MEDUSA_BOARD_REV_0","MEDUSA_BOARD_REV_1", + "MEDUSA_BOARD_REV_2","MEDUSA_BOARD_TYPE", + "HSC_OCP_SLOT_ODD_GPIO1","HSC_OCP_SLOT_ODD_GPIO2", + "HSC_OCP_SLOT_ODD_GPIO3","HSC_OCP_SLOT_EVEN_GPIO1", + "HSC_OCP_SLOT_EVEN_GPIO2","HSC_OCP_SLOT_EVEN_GPIO3", + "ADC_TYPE_0_R","ADC_TYPE_1_R"; + }; + + gpio_ext3: pca9555 at 22 { compatible = "nxp,pca9555"; - reg = <0x22>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; - }; - - gpio at 23 { + reg = <0x22>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "CARD_TYPE_SLOT1","CARD_TYPE_SLOT2", + "CARD_TYPE_SLOT3","CARD_TYPE_SLOT4", + "CARD_TYPE_SLOT5","CARD_TYPE_SLOT6", + "CARD_TYPE_SLOT7","CARD_TYPE_SLOT8", + "OC_P48V_HSC_0_N","FLT_P48V_HSC_0_N", + "PWRGD_P12V_AUX_1","OC_P48V_HSC_1_N", + "FLT_P48V_HSC_1_N","PWRGD_P12V_AUX_1", + "MEDUSA_ADC_EFUSE_TYPE_R","P12V_HSC_TYPE"; + }; + + gpio_ext4: pca9555 at 23 { compatible = "nxp,pca9555"; - reg = <0x23>; + pinctrl-names = "default"; gpio-controller; #gpio-cells = <2>; + reg = <0x23>; + interrupt-parent = <&gpio0>; + interrupts = <94 IRQ_TYPE_LEVEL_LOW>; + gpio-line-names = + "HSC1_ALERT1_R_N","HSC2_ALERT1_R_N", + "HSC3_ALERT1_R_N","HSC4_ALERT1_R_N", + "HSC5_ALERT1_R_N","HSC6_ALERT1_R_N", + "HSC7_ALERT1_R_N","HSC8_ALERT1_R_N", + "HSC1_ALERT2_R_N","HSC2_ALERT2_R_N", + "HSC3_ALERT2_R_N","HSC4_ALERT2_R_N", + "HSC5_ALERT2_R_N","HSC6_ALERT2_R_N", + "HSC7_ALERT2_R_N","HSC8_ALERT2_R_N"; + }; + + power-sensor at 40 { + compatible = "mps,mp5023"; + reg = <0x40>; }; temperature-sensor at 48 { @@ -868,19 +921,29 @@ temperature-sensor at 49 { reg = <0x49>; }; - temperature-sensor at 4a { - compatible = "ti,tmp75"; - reg = <0x4a>; + eeprom at 54 { + compatible = "atmel,24c128"; + reg = <0x54>; }; - temperature-sensor at 4b { - compatible = "ti,tmp75"; - reg = <0x4b>; + power-sensor at 62 { + compatible = "pmbus"; + reg = <0x62>; }; - eeprom at 54 { - compatible = "atmel,24c256"; - reg = <0x54>; + power-sensor at 64 { + compatible = "pmbus"; + reg = <0x64>; + }; + + power-sensor at 65 { + compatible = "pmbus"; + reg = <0x65>; + }; + + power-sensor at 68 { + compatible = "pmbus"; + reg = <0x68>; }; }; @@ -898,6 +961,11 @@ eeprom at 50 { reg = <0x50>; }; + eeprom at 54 { + compatible = "atmel,24c64"; + reg = <0x54>; + }; + rtc at 6f { compatible = "nuvoton,nct3018y"; reg = <0x6f>; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:34 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:34 +0800 Subject: [PATCH linux dev-6.6 v2 10/14] ARM: dts: aspeed: yosemite4: Initialize bmc gpio state In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-11-Delphine_CC_Chiu@wiwynn.com> Initialize bmc gpio state Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 195 ++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index ed2b1200603d..eb3687bfd632 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1271,6 +1271,7 @@ temperature-sensor at 1f { }; }; + &adc0 { ref_voltage = <2500>; status = "okay"; @@ -1298,3 +1299,197 @@ &ehci1 { &uhci { status = "okay"; }; + +&sgpiom0 { + status = "okay"; + ngpios = <128>; + bus-frequency = <48000>; +}; + +&gpio0 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_gpiu2_default &pinctrl_gpiu3_default + &pinctrl_gpiu4_default &pinctrl_gpiu5_default + &pinctrl_gpiu6_default>; + gpio-line-names = + /*A0-A7*/ "","","","","","","","", + /*B0-B7*/ "FLT_HSC_SERVER_SLOT8_N","AC_ON_OFF_BTN_CPLD_SLOT5_N", + "PWRGD_SLOT1_STBY","PWRGD_SLOT2_STBY", + "PWRGD_SLOT3_STBY","PWRGD_SLOT4_STBY","","", + /*C0-C7*/ "PRSNT_NIC3_N","","","","FM_NIC0_WAKE_N", + "FM_NIC1_WAKE_N","","RST_PCIE_SLOT2_N", + /*D0-D7*/ "","","","","","","","", + /*E0-E7*/ "PRSNT_NIC1_N","PRSNT_NIC2_N","","RST_PCIE_SLOT1_N", + "","","","", + /*F0-F7*/ "FM_RESBTN_SLOT1_BMC_N","FM_RESBTN_SLOT2_BMC_N", + "FM_RESBTN_SLOT3_BMC_N","FM_RESBTN_SLOT4_BMC_N", + "PRSNT_SB_SLOT1_N","PRSNT_SB_SLOT2_N", + "PRSNT_SB_SLOT3_N","PRSNT_SB_SLOT4_N", + /*G0-G7*/ "","","","","","","","", + /*H0-H7*/ "","","","","","","","", + /*I0-I7*/ "","","","","","ALT_MEDUSA_ADC_N", + "ALT_SMB_BMC_CPLD2_N", + "INT_SPIDER_ADC_R_N", + /*J0-J7*/ "","","","","","","","", + /*K0-K7*/ "","","","","","","","", + /*L0-L7*/ "","","","","","","ALT_MEDUSA_P12V_EFUSE_N","", + /*M0-M7*/ "EN_NIC0_POWER_BMC_R","EN_NIC1_POWER_BMC_R", + "INT_MEDUSA_IOEXP_TEMP_N","FLT_P12V_NIC0_N", + "INT_SMB_BMC_SLOT1_4_BMC_N", + "AC_ON_OFF_BTN_CPLD_SLOT6_N","","", + /*N0-N7*/ "FLT_HSC_SERVER_SLOT1_N","FLT_HSC_SERVER_SLOT2_N", + "FLT_HSC_SERVER_SLOT3_N","FLT_HSC_SERVER_SLOT4_N", + "FM_BMC_READY_R2","FLT_P12V_STBY_BMC_N","","", + /*O0-O7*/ "AC_ON_OFF_BTN_CPLD_SLOT8_N","RST_SMB_NIC1_R_N", + "RST_SMB_NIC2_R_N","RST_SMB_NIC3_R_N", + "FLT_P3V3_NIC2_N","FLT_P3V3_NIC3_N", + "","", + /*P0-P7*/ "ALT_SMB_BMC_CPLD1_N","'BTN_BMC_R2_N", + "EN_P3V_BAT_SCALED_R","PWRGD_P5V_USB_BMC", + "FM_BMC_RTCRST_R","RST_USB_HUB_R_N", + "FLAG_P5V_USB_BMC_N","", + /*Q0-Q7*/ "AC_ON_OFF_BTN_CPLD_SLOT1_N","AC_ON_OFF_BTN_CPLD_SLOT2_N", + "AC_ON_OFF_BTN_CPLD_SLOT3_N","AC_ON_OFF_BTN_CPLD_SLOT4_N", + "PRSNT_SB_SLOT5_N","PRSNT_SB_SLOT6_N", + "PRSNT_SB_SLOT7_N","PRSNT_SB_SLOT8_N", + /*R0-R7*/ "AC_ON_OFF_BTN_CPLD_SLOT7_N","INT_SMB_BMC_SLOT5_8_BMC_N", + "FM_PWRBRK_NIC_BMC_R2","RST_PCIE_SLOT4_N", + "RST_PCIE_SLOT5_N","RST_PCIE_SLOT6_N", + "RST_PCIE_SLOT7_N","RST_PCIE_SLOT8_N", + /*S0-S7*/ "FM_NIC2_WAKE_N","FM_NIC3_WAKE_N", + "EN_NIC3_POWER_BMC_R","SEL_BMC_JTAG_MUX_R", + "","ALT_P12V_AUX_N","FAST_PROCHOT_N", + "SPI_WP_DISABLE_STATUS_R_N", + /*T0-T7*/ "","","","","","","","", + /*U0-U7*/ "","","FLT_P3V3_NIC1_N","FLT_P12V_NIC1_N", + "FLT_P12V_NIC2_N","FLT_P12V_NIC3_N", + "FLT_P3V3_NIC0_N","", + /*V0-V7*/ "FM_RESBTN_SLOT5_BMC_N","FM_RESBTN_SLOT6_BMC_N", + "FM_RESBTN_SLOT7_BMC_N","FM_RESBTN_SLOT8_BMC_N", + "","","","", + /*W0-W7*/ "PRSNT_TPM_BMC_N","PRSNT_OCP_DEBUG_BMC_N","ALT_TEMP_BMC_N","ALT_RTC_BMC_N", + "","","","", + /*X0-X7*/ "","LT_HSC_SERVER_SLOT6_N","FLT_HSC_SERVER_SLOT7_N","","","", + "PWRGD_SLOT5_STBY","PWRGD_SLOT6_STBY", + /*Y0-Y7*/ "","","SPI_LOCK_REQ_BMC_N","PWRGD_SLOT7_STBY", + "","","EN_NIC2_POWER_BMC_R","", + /*Z0-Z7*/ "EN_P5V_USB_CPLD_R","'FLT_HSC_SERVER_SLOT5_N", + "PWRGD_SLOT8_STBY","","","","",""; + + pin_gpio_b4 { + gpios = ; + input; + }; + pin_gpio_b5 { + gpios = ; + input; + }; + pin_gpio_f0 { + gpios = ; + input; + }; + pin_gpio_f1 { + gpios = ; + input; + }; + pin_gpio_f2 { + gpios = ; + input; + }; + pin_gpio_f3 { + gpios = ; + input; + }; + pin_gpio_f4 { + gpios = ; + input; + }; + pin_gpio_f5 { + gpios = ; + input; + }; + pin_gpio_f6 { + gpios = ; + input; + }; + pin_gpio_f7 { + gpios = ; + input; + }; + pin_gpio_l6 { + gpios = ; + input; + }; + pin_gpio_l7 { + gpios = ; + input; + }; + pin_gpio_s0 { + gpios = ; + input; + }; + pin_gpio_s1 { + gpios = ; + input; + }; + pin_gpio_v0 { + gpios = ; + input; + }; + pin_gpio_v1 { + gpios = ; + input; + }; + pin_gpio_v2 { + gpios = ; + input; + }; + pin_gpio_v3 { + gpios = ; + input; + }; + pin_gpio_w0 { + gpios = ; + input; + }; + pin_gpio_w1 { + gpios = ; + input; + }; + pin_gpio_w2 { + gpios = ; + input; + }; + pin_gpio_w3 { + gpios = ; + input; + }; + pin_gpio_w4 { + gpios = ; + input; + }; + pin_gpio_w5 { + gpios = ; + input; + }; + pin_gpio_w6 { + gpios = ; + input; + }; + pin_gpio_w7 { + gpios = ; + input; + }; + pin_gpio_z3 { + gpios = ; + input; + }; + pin_gpio_z4 { + gpios = ; + input; + }; + pin_gpio_z5 { + gpios = ; + input; + }; +}; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:33 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:33 +0800 Subject: [PATCH linux dev-6.6 v2 09/14] ARM: dts: aspeed: yosemite4: Revise i2c14 and i2c15 schematic change In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-10-Delphine_CC_Chiu@wiwynn.com> Revise i2c14 and i2c15 schematic change: - Revise adc128d818 adc mode for yosemite4 schematic change - Revise ina233 for yosemite4 schematic change - Remove idle state setting for yosemite4 NIC connection Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index ccb5ecd8d9a6..ed2b1200603d 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1010,44 +1010,54 @@ &i2c14 { adc at 1d { compatible = "ti,adc128d818"; reg = <0x1d>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; - adc at 35 { + adc at 36 { compatible = "ti,adc128d818"; - reg = <0x35>; - ti,mode = /bits/ 8 <2>; + reg = <0x36>; + ti,mode = /bits/ 8 <1>; }; adc at 37 { compatible = "ti,adc128d818"; reg = <0x37>; - ti,mode = /bits/ 8 <2>; + ti,mode = /bits/ 8 <1>; }; power-sensor at 40 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x40>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 41 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x41>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 42 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x42>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 43 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x43>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; power-sensor at 44 { - compatible = "ti,ina230"; + compatible = "ti,ina233"; reg = <0x44>; + resistor-calibration = /bits/ 16 <0x0a00>; + current-lsb= /bits/ 16 <0x0001>; }; temperature-sensor at 4e { @@ -1217,7 +1227,6 @@ mctp at 10 { i2c-mux at 72 { compatible = "nxp,pca9544"; - i2c-mux-idle-disconnect; reg = <0x72>; imux24: i2c at 0 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:35 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:35 +0800 Subject: [PATCH linux dev-6.6 v2 11/14] ARM: dts: aspeed: yosemite4: Revise mx31790 fan tach config In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-12-Delphine_CC_Chiu@wiwynn.com> Revise fan tach config for max31790 driver change Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index eb3687bfd632..073f27f1e35f 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1095,8 +1095,18 @@ adc at 1f { pwm at 20{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x20>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; gpio at 22{ @@ -1108,8 +1118,18 @@ gpio at 22{ pwm at 2f{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x2f>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; adc at 33 { @@ -1145,8 +1165,18 @@ adc at 1f { pwm at 20{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x20>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; gpio at 22{ @@ -1158,8 +1188,18 @@ gpio at 22{ pwm at 2f{ compatible = "maxim,max31790"; - pwm-as-tach = <4 5>; + #address-cells = <1>; + #size-cells = <0>; reg = <0x2f>; + channel at 4 { + reg = <4>; + sensor-type = "TACH"; + }; + + channel at 5 { + reg = <5>; + sensor-type = "TACH"; + }; }; adc at 33 { -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:36 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:36 +0800 Subject: [PATCH linux dev-6.6 v2 12/14] ARM: dts: aspeed: yosemite4: add mctp config for NIC In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-13-Delphine_CC_Chiu@wiwynn.com> add mctp config for NIC Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index 073f27f1e35f..c8e3a85b7a11 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1273,40 +1273,64 @@ imux24: i2c at 0 { #address-cells = <1>; #size-cells = <0>; reg = <0>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; imux25: i2c at 1 { #address-cells = <1>; #size-cells = <0>; reg = <1>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; imux26: i2c at 2 { #address-cells = <1>; #size-cells = <0>; reg = <2>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; imux27: i2c at 3 { #address-cells = <1>; #size-cells = <0>; reg = <3>; + mctp-controller; temperature-sensor at 1f { compatible = "ti,tmp421"; reg = <0x1f>; }; + + emc1403 at 3c { + compatible = "smsc,emc1403"; + reg = <0x3c>; + }; }; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:37 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:37 +0800 Subject: [PATCH linux dev-6.6 v2 13/14] ARM: dts: aspeed: yosemite4: support mux to cpld In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-14-Delphine_CC_Chiu@wiwynn.com> Mux pca9544 to cpld was added on EVT HW schematic design, so add dts setting for devices behind mux pca9544 to cpld Signed-off-by: Delphine CC Chiu --- .../aspeed/aspeed-bmc-facebook-yosemite4.dts | 64 ++++++++++++++----- 1 file changed, 49 insertions(+), 15 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index c8e3a85b7a11..fdc33bffd467 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -36,6 +36,10 @@ aliases { i2c31 = &imux31; i2c32 = &imux32; i2c33 = &imux33; + i2c34 = &imux34; + i2c35 = &imux35; + i2c36 = &imux36; + i2c37 = &imux37; }; chosen { @@ -951,24 +955,54 @@ &i2c12 { status = "okay"; bus-frequency = <400000>; - temperature-sensor at 48 { - compatible = "ti,tmp75"; - reg = <0x48>; - }; + i2c-mux at 70 { + compatible = "nxp,pca9544"; + i2c-mux-idle-disconnect; + reg = <0x70>; - eeprom at 50 { - compatible = "atmel,24c128"; - reg = <0x50>; - }; + imux34: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; - eeprom at 54 { - compatible = "atmel,24c64"; - reg = <0x54>; - }; + temperature-sensor at 48 { + compatible = "ti,tmp75"; + reg = <0x48>; + }; + + eeprom at 50 { + compatible = "atmel,24c128"; + reg = <0x50>; + }; - rtc at 6f { - compatible = "nuvoton,nct3018y"; - reg = <0x6f>; + eeprom at 54 { + compatible = "atmel,24c64"; + reg = <0x54>; + }; + + rtc at 6f { + compatible = "nuvoton,nct3018y"; + reg = <0x6f>; + }; + }; + + imux35: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + + imux36: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + }; + + imux37: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + }; }; }; -- 2.25.1 From Delphine_CC_Chiu at wiwynn.com Mon Dec 11 16:57:38 2023 From: Delphine_CC_Chiu at wiwynn.com (Delphine CC Chiu) Date: Mon, 11 Dec 2023 13:57:38 +0800 Subject: [PATCH v2 linux dev-6.6 14/14] ARM: dts: aspeed: yosemite4: Revise gpio name In-Reply-To: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> References: <20231211055738.215773-1-Delphine_CC_Chiu@wiwynn.com> Message-ID: <20231211055738.215773-15-Delphine_CC_Chiu@wiwynn.com> Revise gpio name for EVT schematic changes Signed-off-by: Delphine CC Chiu --- Changelog: - v2 - Correct patch for revising gpio name - v1 - Add patch for revising gpio name --- .../dts/aspeed/aspeed-bmc-facebook-yosemite4.dts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts index fdc33bffd467..15a3bdcfc861 100644 --- a/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-facebook-yosemite4.dts @@ -1414,7 +1414,7 @@ &pinctrl_gpiu4_default &pinctrl_gpiu5_default /*B0-B7*/ "FLT_HSC_SERVER_SLOT8_N","AC_ON_OFF_BTN_CPLD_SLOT5_N", "PWRGD_SLOT1_STBY","PWRGD_SLOT2_STBY", "PWRGD_SLOT3_STBY","PWRGD_SLOT4_STBY","","", - /*C0-C7*/ "PRSNT_NIC3_N","","","","FM_NIC0_WAKE_N", + /*C0-C7*/ "","","","","FM_NIC0_WAKE_N", "FM_NIC1_WAKE_N","","RST_PCIE_SLOT2_N", /*D0-D7*/ "","","","","","","","", /*E0-E7*/ "PRSNT_NIC1_N","PRSNT_NIC2_N","","RST_PCIE_SLOT1_N", @@ -1432,16 +1432,15 @@ &pinctrl_gpiu4_default &pinctrl_gpiu5_default /*K0-K7*/ "","","","","","","","", /*L0-L7*/ "","","","","","","ALT_MEDUSA_P12V_EFUSE_N","", /*M0-M7*/ "EN_NIC0_POWER_BMC_R","EN_NIC1_POWER_BMC_R", - "INT_MEDUSA_IOEXP_TEMP_N","FLT_P12V_NIC0_N", + "INT_MEDUSA_IOEXP_TEMP_N","PRSNT_NIC3_N", "INT_SMB_BMC_SLOT1_4_BMC_N", "AC_ON_OFF_BTN_CPLD_SLOT6_N","","", /*N0-N7*/ "FLT_HSC_SERVER_SLOT1_N","FLT_HSC_SERVER_SLOT2_N", "FLT_HSC_SERVER_SLOT3_N","FLT_HSC_SERVER_SLOT4_N", - "FM_BMC_READY_R2","FLT_P12V_STBY_BMC_N","","", + "FM_BMC_READY_R2","RST_SMB_NIC0_R_N","","", /*O0-O7*/ "AC_ON_OFF_BTN_CPLD_SLOT8_N","RST_SMB_NIC1_R_N", "RST_SMB_NIC2_R_N","RST_SMB_NIC3_R_N", - "FLT_P3V3_NIC2_N","FLT_P3V3_NIC3_N", - "","", + "","","","", /*P0-P7*/ "ALT_SMB_BMC_CPLD1_N","'BTN_BMC_R2_N", "EN_P3V_BAT_SCALED_R","PWRGD_P5V_USB_BMC", "FM_BMC_RTCRST_R","RST_USB_HUB_R_N", @@ -1459,9 +1458,8 @@ &pinctrl_gpiu4_default &pinctrl_gpiu5_default "","ALT_P12V_AUX_N","FAST_PROCHOT_N", "SPI_WP_DISABLE_STATUS_R_N", /*T0-T7*/ "","","","","","","","", - /*U0-U7*/ "","","FLT_P3V3_NIC1_N","FLT_P12V_NIC1_N", - "FLT_P12V_NIC2_N","FLT_P12V_NIC3_N", - "FLT_P3V3_NIC0_N","", + /*U0-U7*/ "","","RST_PCIE_SLOT3_N","", + "","PRSNT_NIC0_N","","", /*V0-V7*/ "FM_RESBTN_SLOT5_BMC_N","FM_RESBTN_SLOT6_BMC_N", "FM_RESBTN_SLOT7_BMC_N","FM_RESBTN_SLOT8_BMC_N", "","","","", -- 2.25.1 From quan at os.amperecomputing.com Mon Dec 11 21:22:15 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 17:22:15 +0700 Subject: [PATCH v4 0/2] i2c: aspeed: Late ack Tx done irqs and handle coalesced start with stop conditions Message-ID: <20231211102217.2436294-1-quan@os.amperecomputing.com> This series consists of two patches to handle the below issues observed when testing with slave mode: + The coalesced stop condition with the start conditions + Early ack'ed of Tx done (ACK and NAK) causing "Unexpected Ack on read request". This series was verified with ast2500 and ast2600. The prior discussion could be found at: https://lore.kernel.org/all/20231208033142.1673232-1-quan at os.amperecomputing.com/ v4: + Switch to use define macro instead of variable [Andrew] + Make the early ack conditionally to avoid unnecessary writel()/readl() [Quan] + Add an extra empty line before the comment in patch 1 [Andrew] v3: + Fix the unconditional write when ack the irqs [Andrew] + Handle the coalesced stop condition with the start conditions [Andrew] + Refactor the code to enhance code readability [Quan] + Revised commit message [Quan] v2: + Split these patches to separate series [Joel] + Added the Fixes lines [Joel] + Fixed multiline comment [Joel] + Refactor irq clearing code [Joel, Guenter] + Revised commit message [Joel, Quan] v1: + These patches are first introduced from this disscusstion https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ Quan Nguyen (2): i2c: aspeed: Handle the coalesced stop conditions with the start conditions. i2c: aspeed: Acknowledge Tx done with and without ACK irq late drivers/i2c/busses/i2c-aspeed.c | 75 +++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 23 deletions(-) -- 2.35.1 From quan at os.amperecomputing.com Mon Dec 11 21:22:16 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 17:22:16 +0700 Subject: [PATCH v4 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231211102217.2436294-1-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> Message-ID: <20231211102217.2436294-2-quan@os.amperecomputing.com> Some masters may drive the transfers with low enough latency between the nak/stop phase of the current command and the start/address phase of the following command that the interrupts are coalesced by the time we process them. Handle the stop conditions before processing SLAVE_MATCH to fix the complaints that sometimes occur below. "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected 0x00000086, but was 0x00000084" Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") Signed-off-by: Quan Nguyen Reviewed-by: Andrew Jeffery Reviewed-by: Andi Shyti --- v4: + Add an extra empty line before the comment [Andrew] Note: I'd like to keep adding Reviewed-by Andrew and Andi for this patch eventhough there is an extra empty line added before the comment as mentioned above. Thanks for the review. v3: + Change to handle the coalesced stop condition with the start conditions [Andrew] + Revised commit message [Quan] v2: + Split to separate series [Joel] + Added the Fixes line [Joel] + Revised commit message [Quan] v1: + First introduced in https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ --- drivers/i2c/busses/i2c-aspeed.c | 48 ++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 28e2a5fc4528..5511fd46a65e 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -249,18 +249,46 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) if (!slave) return 0; - command = readl(bus->base + ASPEED_I2C_CMD_REG); + /* + * Handle stop conditions early, prior to SLAVE_MATCH. Some masters may drive + * transfers with low enough latency between the nak/stop phase of the current + * command and the start/address phase of the following command that the + * interrupts are coalesced by the time we process them. + */ + if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { + irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; + bus->slave_state = ASPEED_I2C_SLAVE_STOP; + } + + if (irq_status & ASPEED_I2CD_INTR_TX_NAK && + bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { + irq_handled |= ASPEED_I2CD_INTR_TX_NAK; + bus->slave_state = ASPEED_I2C_SLAVE_STOP; + } + + /* Propagate any stop conditions to the slave implementation. */ + if (bus->slave_state == ASPEED_I2C_SLAVE_STOP) { + i2c_slave_event(slave, I2C_SLAVE_STOP, &value); + bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; + } - /* Slave was requested, restart state machine. */ + /* + * Now that we've dealt with any potentially coalesced stop conditions, + * address any start conditions. + */ if (irq_status & ASPEED_I2CD_INTR_SLAVE_MATCH) { irq_handled |= ASPEED_I2CD_INTR_SLAVE_MATCH; bus->slave_state = ASPEED_I2C_SLAVE_START; } - /* Slave is not currently active, irq was for someone else. */ + /* + * If the slave has been stopped and not started then slave interrupt + * handling is complete. + */ if (bus->slave_state == ASPEED_I2C_SLAVE_INACTIVE) return irq_handled; + command = readl(bus->base + ASPEED_I2C_CMD_REG); dev_dbg(bus->dev, "slave irq status 0x%08x, cmd 0x%08x\n", irq_status, command); @@ -279,17 +307,6 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) irq_handled |= ASPEED_I2CD_INTR_RX_DONE; } - /* Slave was asked to stop. */ - if (irq_status & ASPEED_I2CD_INTR_NORMAL_STOP) { - irq_handled |= ASPEED_I2CD_INTR_NORMAL_STOP; - bus->slave_state = ASPEED_I2C_SLAVE_STOP; - } - if (irq_status & ASPEED_I2CD_INTR_TX_NAK && - bus->slave_state == ASPEED_I2C_SLAVE_READ_PROCESSED) { - irq_handled |= ASPEED_I2CD_INTR_TX_NAK; - bus->slave_state = ASPEED_I2C_SLAVE_STOP; - } - switch (bus->slave_state) { case ASPEED_I2C_SLAVE_READ_REQUESTED: if (unlikely(irq_status & ASPEED_I2CD_INTR_TX_ACK)) @@ -324,8 +341,7 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status) i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value); break; case ASPEED_I2C_SLAVE_STOP: - i2c_slave_event(slave, I2C_SLAVE_STOP, &value); - bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; + /* Stop event handling is done early. Unreachable. */ break; case ASPEED_I2C_SLAVE_START: /* Slave was just started. Waiting for the next event. */; -- 2.35.1 From quan at os.amperecomputing.com Mon Dec 11 21:22:17 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 11 Dec 2023 17:22:17 +0700 Subject: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231211102217.2436294-1-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> Message-ID: <20231211102217.2436294-3-quan@os.amperecomputing.com> Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") acknowledges most interrupts early before the slave irq handler is executed, except for the "Receive Done Interrupt status" which is acknowledged late in the interrupt. However, it has been observed that the early acknowledgment of "Transmit Done Interrupt Status" (with ACK or NACK) often causes the interrupt to be raised in READ REQUEST state, that shows the "Unexpected ACK on read request." complaint messages. Assuming that the "Transmit Done" interrupt should only be acknowledged once it is truly processed, this commit fixes that issue by acknowledging interrupts for both ACK and NACK cases late in the interrupt handler. Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") Signed-off-by: Quan Nguyen --- v4: + Switch to use define macro instead of variable [Andrew] + Make the early ack conditionally to avoid unnecessary writel()/readl() [Quan] v3: + Fix the unconditinal write when ack the irqs [Andrew] + Refactor the code to enhance code readability [Quan] + Fix grammar in commit message [Quan] v2: + Split to separate series [Joel] + Added the Fixes line [Joel] + Fixed multiline comment [Joel] + Refactor irq clearing code [Joel, Guenter] + Revised commit message [Joel] + Revised commit message [Quan] + About a note to remind why the readl() should immediately follow the writel() to fix the race condition when clearing irq status from commit c926c87b8e36 ("i2c: aspeed: Avoid i2c interrupt status clear race condition"), I think it looks straight forward in this patch and decided not to add that note. [Joel] v1: + First introduced in https://lore.kernel.org/all/20210519074934.20712-1-quan at os.amperecomputing.com/ --- drivers/i2c/busses/i2c-aspeed.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 5511fd46a65e..0f67218cf04a 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -93,6 +93,10 @@ ASPEED_I2CD_INTR_RX_DONE | \ ASPEED_I2CD_INTR_TX_NAK | \ ASPEED_I2CD_INTR_TX_ACK) +#define ASPEED_I2CD_INTR_ACK_RX_TX \ + (ASPEED_I2CD_INTR_RX_DONE | \ + ASPEED_I2CD_INTR_TX_ACK | \ + ASPEED_I2CD_INTR_TX_NAK) /* 0x14 : I2CD Command/Status Register */ #define ASPEED_I2CD_SCL_LINE_STS BIT(18) @@ -622,10 +626,19 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) spin_lock(&bus->lock); irq_received = readl(bus->base + ASPEED_I2C_INTR_STS_REG); - /* Ack all interrupts except for Rx done */ - writel(irq_received & ~ASPEED_I2CD_INTR_RX_DONE, - bus->base + ASPEED_I2C_INTR_STS_REG); - readl(bus->base + ASPEED_I2C_INTR_STS_REG); + + /* + * Early acking of INTR_RX_DONE and INTR_TX_[ACK|NAK] would indicate HW to + * start receiving or sending new data, and this may cause a race condition + * as the irq handler has not yet handled these irqs but is being acked. + * Let's ack them late at the end of the irq handler when those are truly processed. + */ + if (irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX) { + writel(irq_received & ~ASPEED_I2CD_INTR_ACK_RX_TX, + bus->base + ASPEED_I2C_INTR_STS_REG); + readl(bus->base + ASPEED_I2C_INTR_STS_REG); + } + irq_received &= ASPEED_I2CD_INTR_RECV_MASK; irq_remaining = irq_received; @@ -668,12 +681,12 @@ static irqreturn_t aspeed_i2c_bus_irq(int irq, void *dev_id) "irq handled != irq. expected 0x%08x, but was 0x%08x\n", irq_received, irq_handled); - /* Ack Rx done */ - if (irq_received & ASPEED_I2CD_INTR_RX_DONE) { - writel(ASPEED_I2CD_INTR_RX_DONE, + if (irq_received & ASPEED_I2CD_INTR_ACK_RX_TX) { + writel(irq_received & ASPEED_I2CD_INTR_ACK_RX_TX, bus->base + ASPEED_I2C_INTR_STS_REG); readl(bus->base + ASPEED_I2C_INTR_STS_REG); } + spin_unlock(&bus->lock); return irq_remaining ? IRQ_NONE : IRQ_HANDLED; } -- 2.35.1 From andriy.shevchenko at linux.intel.com Tue Dec 12 02:42:39 2023 From: andriy.shevchenko at linux.intel.com (Andy Shevchenko) Date: Mon, 11 Dec 2023 17:42:39 +0200 Subject: [PATCH v1 1/1] pinctrl: nuvoton: Constify wpcm450_groups Message-ID: <20231211154239.4190429-1-andriy.shevchenko@linux.intel.com> There is no modifications are assumed for wpcm450_groups. Constify it. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c index 4589900244c7..cdad4ef11a2f 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c @@ -474,7 +474,7 @@ enum { #undef WPCM450_GRP }; -static struct pingroup wpcm450_groups[] = { +static const struct pingroup wpcm450_groups[] = { #define WPCM450_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins)) WPCM450_GRPS #undef WPCM450_GRP -- 2.43.0.rc1.1.gbec44491f096 From andrew at codeconstruct.com.au Tue Dec 12 10:03:17 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Tue, 12 Dec 2023 09:33:17 +1030 Subject: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231211102217.2436294-3-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-3-quan@os.amperecomputing.com> Message-ID: <2eab42cde34723a195e7a0287db08b25f8388a3b.camel@codeconstruct.com.au> On Mon, 2023-12-11 at 17:22 +0700, Quan Nguyen wrote: > Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in > interrupt handler") acknowledges most interrupts early before the slave > irq handler is executed, except for the "Receive Done Interrupt status" > which is acknowledged late in the interrupt. > However, it has been observed that the early acknowledgment of "Transmit > Done Interrupt Status" (with ACK or NACK) often causes the interrupt to > be raised in READ REQUEST state, that shows the > "Unexpected ACK on read request." complaint messages. > > Assuming that the "Transmit Done" interrupt should only be acknowledged > once it is truly processed, this commit fixes that issue by acknowledging > interrupts for both ACK and NACK cases late in the interrupt handler. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > Signed-off-by: Quan Nguyen Reviewed-by: Andrew Jeffery Thanks Quan! From baneric926 at gmail.com Fri Dec 8 14:05:20 2023 From: baneric926 at gmail.com (Ban Feng) Date: Fri, 8 Dec 2023 11:05:20 +0800 Subject: [PATCH v1 1/2] dt-bindings: hwmon: Add nct736x bindings In-Reply-To: <4770f744-2309-4de0-8aaf-a221f69c08b7@linaro.org> References: <20231204055650.788388-1-kcfeng0@nuvoton.com> <20231204055650.788388-2-kcfeng0@nuvoton.com> <94607c47-9824-4e2c-8f22-99ca2e088b27@linaro.org> <4770f744-2309-4de0-8aaf-a221f69c08b7@linaro.org> Message-ID: Hi Krzysztof, On Tuesday, December 5, 2023, Krzysztof Kozlowski wrote: > > On 05/12/2023 10:31, Ban Feng wrote: > > Hi Krzysztof, > > > > On Mon, Dec 4, 2023 at 4:04?PM Krzysztof Kozlowski > > wrote: > >> > >> On 04/12/2023 06:56, baneric926 at gmail.com wrote: > >>> From: Ban Feng > >>> > >>> This change documents the device tree bindings for the Nuvoton > >>> NCT7362Y, NCT7363Y driver. > >>> > >>> Signed-off-by: Ban Feng > >>> --- > >>> .../bindings/hwmon/nuvoton,nct736x.yaml | 80 +++++++++++++++++++ > >>> MAINTAINERS | 6 ++ > >>> 2 files changed, 86 insertions(+) > >>> create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml > >>> > >>> diff --git a/Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml b/Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml > >>> new file mode 100644 > >>> index 000000000000..f98fd260a20f > >>> --- /dev/null > >>> +++ b/Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml > >>> @@ -0,0 +1,80 @@ > >>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > >>> +%YAML 1.2 > >>> +--- > >>> + > >>> +$id: http://devicetree.org/schemas/hwmon/nuvoton,nct736x.yaml# > >>> +$schema: http://devicetree.org/meta-schemas/core.yaml# > >>> + > >>> +title: Nuvoton NCT736X Hardware Monitoring IC > >>> + > >>> +maintainers: > >>> + - Ban Feng > >>> + > >>> +description: | > >>> + The NCT736X is a Fan controller which provides up to 16 independent > >>> + FAN input monitors, and up to 16 independent PWM output with SMBus interface. > >>> + Besides, NCT7363Y has a built-in watchdog timer which is used for > >>> + conditionally generating a system reset output (INT#). > >>> + > >>> +additionalProperties: false > >> > >> Please place it just like other bindings are placing it. Not in some > >> random order. See example-schema. > > > > ok, I'll move additionalProperties to the correct place. > > > >> > >> You should use common fan properties. If it was not merged yet, you must > >> rebase on patchset on LKML and mention the dependency in the change log > >> (---). > > > > please kindly see below > > > >> > >>> + > >>> +properties: > >>> + compatible: > >>> + enum: > >>> + - nuvoton,nct7362 > >>> + - nuvoton,nct7363 > >>> + > >>> + reg: > >>> + maxItems: 1 > >>> + > >>> + nuvoton,pwm-mask: > >>> + description: | > >>> + each bit means PWMx enable/disable setting, where x = 0~15. > >>> + 0: disabled, 1: enabled > >>> + $ref: /schemas/types.yaml#/definitions/uint32 > >>> + minimum: 0x0 > >>> + maximum: 0xFFFF > >>> + default: 0x0 > >> > >> Use pwms, not own property for this. > > > > NCT736X has 16 funtion pins, they can be > > GPIO/PWM/FANIN/Reserved_or_ALERT#, and default is GPIO. > > We would like to add such a property that can configure the function > > pin for pin0~7 and pin10~17. > > It looks you are writing custom pinctrl instead of using standard > bindings and frameworks. Please kindly see below > > > > > > My original design is only for PWM/FANIN, however, > > I noticed that we can change the design to "nuvoton,pin[0-7]$" and > > "nuvoton,pin[10-17]$", like example in adt7475.yaml. > > I'm not sure if this can be accepted or not, please kindly review this. > > It looks like the same problem as with other fan/Nuvoton bindings we > discussed some time ago on the lists. > > Please do not duplicate threads, work and reviews: > https://lore.kernel.org/all/20230607101827.8544-5-zev at bewilderbeest.net/ > > I already gave same comments there. Thanks for your kindly sharing. I noticed that [1] defines some useful properties, pwms and tach-ch, like you mentioned. Therefore, I'll modify our design to follow the common fan properties in v2. [1] https://lists.openwall.net/linux-kernel/2023/11/07/406 > > > >>> + nuvoton,wdt-timeout: > >>> + description: | > >>> + Watchdog Timer time configuration for NCT7363Y, as below > >>> + 0: 15 sec (default) > >>> + 1: 7.5 sec > >>> + 2: 3.75 sec > >>> + 3: 30 sec > >>> + $ref: /schemas/types.yaml#/definitions/uint32 > >>> + enum: [0, 1, 2, 3] > >>> + default: 0 > >> > >> Nope, reference watchdog.yaml and use its properties. See other watchdog > >> bindings for examples. > > > > NCT7363 has a built-in watchdog timer which is used for conditionally > > generating a system reset > > output (INT#) if the microcontroller or microprocessor stops to > > periodically send a pulse signal or > > interface communication access signal like SCL signal from SMBus interface. > > > > We only consider "Watchdog Timer Configuration Register" enable bit > > and timeout setting. > > Should we still need to add struct watchdog_device to struct nct736x_data? > > I do not see correlation between watchdog.yaml and some struct. I did > not write anything about driver, so I don't understand your comments. > > Anyway, I don't like that we are duplicating entire effort and our > review. Please join existing discussions, threads and build on top of it. > Thanks, I'll remove unused function in hwmon subsystem, and consider a watchdog subsystem design if necessary. > > Best regards, > Krzysztof > From u.kleine-koenig at pengutronix.de Mon Dec 11 09:12:15 2023 From: u.kleine-koenig at pengutronix.de (=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=) Date: Sun, 10 Dec 2023 23:12:15 +0100 Subject: [PATCH 00/12] hwrng: Convert to platform remove callback returning Message-ID: Hello, this series converts all hwrng platform drivers to use .remove_new. See commit 5c5a7680e67b ("platform: Provide a remove callback that returns no value") for details and the eventual goal. All driver conversions are trivial as all their remove callbacks return 0 (as good drivers should do). All patches are pairwise independant. These patches should go in via the usual hwrng tree. It's merge window material. Best regards Uwe Uwe Kleine-K?nig (12): hwrng: atmel - Convert to platform remove callback returning void hwrng: cctrng - Convert to platform remove callback returning void hwrng: exynos - Convert to platform remove callback returning void hwrng: ingenic - Convert to platform remove callback returning void hwrng: ks-sa - Convert to platform remove callback returning void hwrng: mxc - Convert to platform remove callback returning void hwrng: n2 - Convert to platform remove callback returning void hwrng: npcm - Convert to platform remove callback returning void hwrng: omap - Convert to platform remove callback returning void hwrng: stm32 - Convert to platform remove callback returning void hwrng: timeriomem - Convert to platform remove callback returning void hwrng: xgene - Convert to platform remove callback returning void drivers/char/hw_random/atmel-rng.c | 6 ++---- drivers/char/hw_random/cctrng.c | 6 ++---- drivers/char/hw_random/exynos-trng.c | 6 ++---- drivers/char/hw_random/ingenic-rng.c | 6 ++---- drivers/char/hw_random/ks-sa-rng.c | 6 ++---- drivers/char/hw_random/mxc-rnga.c | 6 ++---- drivers/char/hw_random/n2-drv.c | 6 ++---- drivers/char/hw_random/npcm-rng.c | 6 ++---- drivers/char/hw_random/omap-rng.c | 6 ++---- drivers/char/hw_random/stm32-rng.c | 6 ++---- drivers/char/hw_random/timeriomem-rng.c | 6 ++---- drivers/char/hw_random/xgene-rng.c | 6 ++---- 12 files changed, 24 insertions(+), 48 deletions(-) base-commit: bc63de6e6ba0b16652c5fb4b9c9916b9e7ca1f23 -- 2.42.0 From joel at jms.id.au Tue Dec 12 13:12:18 2023 From: joel at jms.id.au (Joel Stanley) Date: Tue, 12 Dec 2023 12:42:18 +1030 Subject: [PATCH linux dev-6.5 v4 0/2] LTC4286 and LTC4287 driver support In-Reply-To: References: <20231108082019.1601366-1-Delphine_CC_Chiu@Wiwynn.com> Message-ID: On Wed, 15 Nov 2023 at 19:24, Delphine_CC_Chiu/WYHQ/Wiwynn wrote: > > > -----Original Message----- > > From: Joel Stanley > > Sent: Friday, November 10, 2023 10:35 AM > > To: Delphine_CC_Chiu/WYHQ/Wiwynn ; > > Andrew Jeffery > > Cc: patrick at stwcx.xyz; openbmc at lists.ozlabs.org > > Subject: Re: [PATCH linux dev-6.5 v4 0/2] LTC4286 and LTC4287 driver support > > > > Security Reminder: Please be aware that this email is sent by an external > > sender. > > > > On Wed, 8 Nov 2023 at 21:51, Joel Stanley wrote: > > > > > > On Wed, 8 Nov 2023 at 18:50, Delphine CC Chiu > > > wrote: > > > > > > > > v4 - Add LTC4286 and LTC4287 binding document > > > > - Add LTC4286 and LTC4287 driver > > > > > > This is v4, but the first version you've sent to the openbmc list. I > > > can't see an upstream v4, and v3 has changes requested. > > > > > > It would be best if you finished getting review from Guneter, and then > > > sent that version to the openbmc list for merging. Include a link to > > > the upstream submission in your cover letter so we know what is going > > > on. > > > > I didn't get a response from you. > > > > I did see you posted some more patches, both to the upstream list and to > > openbmc. It's not helpful, please get your patches reviewed upstream and once > > you've got them applied there, then send them to the openbmc list. > > > > Can you please respond to my mail if this makes sense and you agree. > > Sorry for not responding you. > We agree with your suggestion. > However, we have discussed with upstream back and forth. > We almost complete this driver. > Moreover, other projects in OpenBmc want to use this driver. > But we are not sure about when this driver could be merged. > So, we are wondering if there is any chance you can merge this driver first for OpenBmc use. You need to make this case when sending the backport. Please include that information in the cover letter, and make your case as to why we should spend the extra development effort carrying the patch that is still under review. Currently you seem to send the patches to both the upstream list and to openbmc at the same time, which does not work for me. I have some new rules for getting the patches merged into openbmc: 1. Do not send them for backporting to the dev-6.6 branch until they have been reviewed upstream. This means you have Reviewed-by or Acked-by tags on at least a majority of the patches in a series before you send them to the openbmc list. 2. Find reviewers for your upstream patches. Get other Facebook employees, get other openbmc contributors to review your patches. A good way to encourage others to review your patches is to first review thiers. 3. When you do send the patches for backporting, include a justification in the cover letter for why they should be backported. For example: "These patches are merged upstream" or "the changes under active review, but we wish to have them in the openbmc tree because it has been ongoing for more than two weeks". Your latest upstream patchset produces a large number of warnings when I applied it to the 6.7-rc1 tree. This shows you are not compiling your changes before submitting. Please engage with me and the other developers on this issue so we can help each other get the changes up to scratch and merged. Cheers, Joel From joel at jms.id.au Tue Dec 12 13:39:56 2023 From: joel at jms.id.au (Joel Stanley) Date: Tue, 12 Dec 2023 13:09:56 +1030 Subject: [PATCH v4 0/2] i2c: aspeed: Late ack Tx done irqs and handle coalesced start with stop conditions In-Reply-To: <20231211102217.2436294-1-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> Message-ID: On Mon, 11 Dec 2023 at 20:52, Quan Nguyen wrote: > > This series consists of two patches to handle the below issues observed > when testing with slave mode: > + The coalesced stop condition with the start conditions > + Early ack'ed of Tx done (ACK and NAK) causing "Unexpected Ack on > read request". Looks good. I've reached out to a few people who use slave mode to ask for review and testing on hardware. As long as they don't come back with issues, we should get this merged and backported to stable. Reviewed-by: Joel Stanley Cheers, Joel From andrew at codeconstruct.com.au Tue Dec 12 16:02:09 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Tue, 12 Dec 2023 15:32:09 +1030 Subject: [PATCH v4 0/2] i2c: aspeed: Late ack Tx done irqs and handle coalesced start with stop conditions In-Reply-To: References: <20231211102217.2436294-1-quan@os.amperecomputing.com> Message-ID: On Tue, 2023-12-12 at 13:09 +1030, Joel Stanley wrote: > On Mon, 11 Dec 2023 at 20:52, Quan Nguyen wrote: > > > > This series consists of two patches to handle the below issues observed > > when testing with slave mode: > > + The coalesced stop condition with the start conditions > > + Early ack'ed of Tx done (ACK and NAK) causing "Unexpected Ack on > > read request". > > Looks good. I've reached out to a few people who use slave mode to ask > for review and testing on hardware. As long as they don't come back > with issues, we should get this merged and backported to stable. > > Reviewed-by: Joel Stanley I've dropped a build with the patches onto an AST2600 EVB and lightly exercised the affected paths using NVMe-MI over MCTP to a Micron 7450. Tested-by: Andrew Jeffery Andrew From jim.t90615 at gmail.com Tue Dec 12 17:51:44 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Tue, 12 Dec 2023 14:51:44 +0800 Subject: [PATCH v9 0/3] Add Nuvoton NPCM SGPIO feature Message-ID: <20231212065147.3475413-1-jim.t90615@gmail.com> This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). NPCM7xx/NPCM8xx have two sgpio module each module can support up to 64 output pins,and up to 64 input pin, the pin is only for GPI or GPO. GPIO pins have sequential, First half is GPO and second half is GPI. Jim Liu (3): dt-bindings: gpio: add NPCM sgpio driver bindings arm: dts: nuvoton: npcm: Add sgpio feature gpio: nuvoton: Add Nuvoton NPCM sgpio driver .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++ .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 + drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 635 ++++++++++++++++++ 5 files changed, 753 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml create mode 100644 drivers/gpio/gpio-npcm-sgpio.c -- 2.25.1 From jim.t90615 at gmail.com Tue Dec 12 17:51:45 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Tue, 12 Dec 2023 14:51:45 +0800 Subject: [PATCH v9 1/3] dt-bindings: gpio: add NPCM sgpio driver bindings In-Reply-To: <20231212065147.3475413-1-jim.t90615@gmail.com> References: <20231212065147.3475413-1-jim.t90615@gmail.com> Message-ID: <20231212065147.3475413-2-jim.t90615@gmail.com> Add dt-bindings document for the Nuvoton NPCM7xx sgpio driver Signed-off-by: Jim Liu Reviewed-by: Linus Walleij Reviewed-by: Rob Herring --- Changes for v9: - no changed Changes for v8: - no changed Changes for v7: - no changed --- .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml new file mode 100644 index 000000000000..84e0dbcb066c --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/nuvoton,sgpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton SGPIO controller + +maintainers: + - Jim LIU + +description: | + This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. + Nuvoton NPCM7xx SGPIO module is combine serial to parallel IC (HC595) + and parallel to serial IC (HC165), and use APB3 clock to control it. + This interface has 4 pins (D_out , D_in, S_CLK, LDSH). + NPCM7xx/NPCM8xx have two sgpio module each module can support up + to 64 output pins,and up to 64 input pin, the pin is only for gpi or gpo. + GPIO pins have sequential, First half is gpo and second half is gpi. + GPIO pins can be programmed to support the following options + - Support interrupt option for each input port and various interrupt + sensitivity option (level-high, level-low, edge-high, edge-low) + - ngpios is number of nuvoton,input-ngpios GPIO lines and nuvoton,output-ngpios GPIO lines. + nuvoton,input-ngpios GPIO lines is only for gpi. + nuvoton,output-ngpios GPIO lines is only for gpo. + +properties: + compatible: + enum: + - nuvoton,npcm750-sgpio + - nuvoton,npcm845-sgpio + + reg: + maxItems: 1 + + gpio-controller: true + + '#gpio-cells': + const: 2 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + nuvoton,input-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines is only for gpi. + minimum: 0 + maximum: 64 + + nuvoton,output-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines is only for gpo. + minimum: 0 + maximum: 64 + +required: + - compatible + - reg + - gpio-controller + - '#gpio-cells' + - interrupts + - nuvoton,input-ngpios + - nuvoton,output-ngpios + - clocks + +additionalProperties: false + +examples: + - | + #include + #include + gpio8: gpio at 101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + }; -- 2.25.1 From jim.t90615 at gmail.com Tue Dec 12 17:51:46 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Tue, 12 Dec 2023 14:51:46 +0800 Subject: [PATCH v9 2/3] arm: dts: nuvoton: npcm: Add sgpio feature In-Reply-To: <20231212065147.3475413-1-jim.t90615@gmail.com> References: <20231212065147.3475413-1-jim.t90615@gmail.com> Message-ID: <20231212065147.3475413-3-jim.t90615@gmail.com> Add the SGPIO controller to the NPCM7xx devicetree Signed-off-by: Jim Liu --- Changes for v9: - no changed Changes for v8: - no changed Changes for v7: - no changed --- .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi b/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi index 868454ae6bde..df91517a4842 100644 --- a/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi +++ b/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi @@ -372,6 +372,30 @@ &fanin12_pins &fanin13_pins status = "disabled"; }; + gpio8: gpio at 101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + + gpio9: gpio at 102000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x102000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + i2c0: i2c at 80000 { reg = <0x80000 0x1000>; compatible = "nuvoton,npcm750-i2c"; -- 2.25.1 From jim.t90615 at gmail.com Tue Dec 12 17:51:47 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Tue, 12 Dec 2023 14:51:47 +0800 Subject: [PATCH v9 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: <20231212065147.3475413-1-jim.t90615@gmail.com> References: <20231212065147.3475413-1-jim.t90615@gmail.com> Message-ID: <20231212065147.3475413-4-jim.t90615@gmail.com> Add Nuvoton BMC NPCM7xx/NPCM8xx sgpio driver support. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). BMC can use this driver to increase 64 GPI pins and 64 GPO pins to use. Signed-off-by: Jim Liu --- Changes for v9: - fix kernel rebot test warning Changes for v8: - Remove OF_GPIO/GPIO_GENERIC and redundant assignments - Use GENMASK() and BIT() - Use dev_WARN and dev_err_probe - Check indentation issue - Use raw_spinlock_t Changes for v7: - Remove unused variable - Remove return in bank_reg function - Fix warning for const issue --- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 635 +++++++++++++++++++++++++++++++++ 3 files changed, 643 insertions(+) create mode 100644 drivers/gpio/gpio-npcm-sgpio.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b3a133ed31ee..efbdc93819d4 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -478,6 +478,13 @@ config GPIO_MXS select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_NPCM_SGPIO + bool "Nuvoton SGPIO support" + depends on ARCH_NPCM || COMPILE_TEST + select GPIOLIB_IRQCHIP + help + Say Y here to support Nuvoton NPCM7XX/NPCM8XX SGPIO functionality. + config GPIO_OCTEON tristate "Cavium OCTEON GPIO" depends on CAVIUM_OCTEON_SOC diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index eb73b5d633eb..373aa2943de5 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o +obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o diff --git a/drivers/gpio/gpio-npcm-sgpio.c b/drivers/gpio/gpio-npcm-sgpio.c new file mode 100644 index 000000000000..1fb9750cb70e --- /dev/null +++ b/drivers/gpio/gpio-npcm-sgpio.c @@ -0,0 +1,635 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Nuvoton NPCM Serial GPIO Driver + * + * Copyright (C) 2021 Nuvoton Technologies + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_NR_HW_SGPIO 64 + +#define NPCM_IOXCFG1 0x2A +#define NPCM_IOXCFG1_SFT_CLK GENMASK(3, 0) +#define NPCM_IOXCFG1_SCLK_POL BIT(4) +#define NPCM_IOXCFG1_LDSH_POL BIT(5) + +#define NPCM_IOXCTS 0x28 +#define NPCM_IOXCTS_IOXIF_EN BIT(7) +#define NPCM_IOXCTS_RD_MODE GENMASK(2, 1) +#define NPCM_IOXCTS_RD_MODE_PERIODIC BIT(2) + +#define NPCM_IOXCFG2 0x2B +#define NPCM_IOXCFG2_PORT GENMASK(3, 0) + +#define NPCM_IXOEVCFG_MASK GENMASK(1, 0) +#define NPCM_IXOEVCFG_FALLING BIT(1) +#define NPCM_IXOEVCFG_RISING BIT(0) +#define NPCM_IXOEVCFG_BOTH (NPCM_IXOEVCFG_FALLING | NPCM_IXOEVCFG_RISING) + +#define NPCM_CLK_MHZ 8000000 + +#define GPIO_BANK(x) ((x) / 8) +#define GPIO_BIT(x) ((x) % 8) + +/* + * Select the frequency of shift clock. + * The shift clock is a division of the APB clock. + */ +struct npcm_clk_cfg { + unsigned int *sft_clk; + unsigned int *clk_sel; + unsigned int cfg_opt; +}; + +struct npcm_sgpio { + struct gpio_chip chip; + struct clk *pclk; + struct irq_chip intc; + raw_spinlock_t lock; /*protect event config*/ + void __iomem *base; + int irq; + u8 nin_sgpio; + u8 nout_sgpio; + u8 in_port; + u8 out_port; + u8 int_type[MAX_NR_HW_SGPIO]; +}; + +struct npcm_sgpio_bank { + u8 rdata_reg; + u8 wdata_reg; + u8 event_config; + u8 event_status; +}; + +enum npcm_sgpio_reg { + READ_DATA, + WRITE_DATA, + EVENT_CFG, + EVENT_STS, +}; + +static const struct npcm_sgpio_bank npcm_sgpio_banks[] = { + { + .wdata_reg = 0x00, + .rdata_reg = 0x08, + .event_config = 0x10, + .event_status = 0x20, + }, + { + .wdata_reg = 0x01, + .rdata_reg = 0x09, + .event_config = 0x12, + .event_status = 0x21, + }, + { + .wdata_reg = 0x02, + .rdata_reg = 0x0a, + .event_config = 0x14, + .event_status = 0x22, + }, + { + .wdata_reg = 0x03, + .rdata_reg = 0x0b, + .event_config = 0x16, + .event_status = 0x23, + }, + { + .wdata_reg = 0x04, + .rdata_reg = 0x0c, + .event_config = 0x18, + .event_status = 0x24, + }, + { + .wdata_reg = 0x05, + .rdata_reg = 0x0d, + .event_config = 0x1a, + .event_status = 0x25, + }, + { + .wdata_reg = 0x06, + .rdata_reg = 0x0e, + .event_config = 0x1c, + .event_status = 0x26, + }, + { + .wdata_reg = 0x07, + .rdata_reg = 0x0f, + .event_config = 0x1e, + .event_status = 0x27, + }, + +}; + +static void __iomem *bank_reg(struct npcm_sgpio *gpio, + const struct npcm_sgpio_bank *bank, + const enum npcm_sgpio_reg reg) +{ + switch (reg) { + case READ_DATA: + return gpio->base + bank->rdata_reg; + case WRITE_DATA: + return gpio->base + bank->wdata_reg; + case EVENT_CFG: + return gpio->base + bank->event_config; + case EVENT_STS: + return gpio->base + bank->event_status; + default: + /* actually if code runs to here, it's an error case */ + dev_WARN(gpio->chip.parent, "Getting here is an error condition"); + } + return 0; +} + +static const struct npcm_sgpio_bank *offset_to_bank(unsigned int offset) +{ + unsigned int bank = GPIO_BANK(offset); + + return &npcm_sgpio_banks[bank]; +} + +static void irqd_to_npcm_sgpio_data(struct irq_data *d, + struct npcm_sgpio **gpio, + const struct npcm_sgpio_bank **bank, + u8 *bit, unsigned int *offset) +{ + struct npcm_sgpio *internal; + + *offset = irqd_to_hwirq(d); + internal = irq_data_get_irq_chip_data(d); + + *gpio = internal; + *offset -= internal->nout_sgpio; + *bank = offset_to_bank(*offset); + *bit = GPIO_BIT(*offset); +} + +static int npcm_sgpio_init_port(struct npcm_sgpio *gpio) +{ + u8 in_port, out_port, set_port, reg; + + in_port = GPIO_BANK(gpio->nin_sgpio); + if (GPIO_BIT(gpio->nin_sgpio) > 0) + in_port += 1; + + out_port = GPIO_BANK(gpio->nout_sgpio); + if (GPIO_BIT(gpio->nout_sgpio) > 0) + out_port += 1; + + gpio->in_port = in_port; + gpio->out_port = out_port; + set_port = ((out_port & NPCM_IOXCFG2_PORT) << 4) | (in_port & NPCM_IOXCFG2_PORT); + iowrite8(set_port, gpio->base + NPCM_IOXCFG2); + + reg = ioread8(gpio->base + NPCM_IOXCFG2); + + return reg == set_port ? 0 : -EINVAL; + +} + +static int npcm_sgpio_dir_in(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + return offset < gpio->nout_sgpio ? -EINVAL : 0; + +} + +static int npcm_sgpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val) +{ + gc->set(gc, offset, val); + + return 0; + +} + +static int npcm_sgpio_get_direction(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + if (offset > gpio->chip.ngpio) + return -EINVAL; + + if (offset < gpio->nout_sgpio) + return GPIO_LINE_DIRECTION_OUT; + + return GPIO_LINE_DIRECTION_IN; +} + +static void npcm_sgpio_set(struct gpio_chip *gc, unsigned int offset, int val) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + const struct npcm_sgpio_bank *bank = offset_to_bank(offset); + void __iomem *addr; + u8 reg = 0; + + addr = bank_reg(gpio, bank, WRITE_DATA); + reg = ioread8(addr); + + if (val) + reg |= (val << GPIO_BIT(offset)); + else + reg &= ~(1 << GPIO_BIT(offset)); + + iowrite8(reg, addr); +} + +static int npcm_sgpio_get(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + const struct npcm_sgpio_bank *bank; + void __iomem *addr; + u8 reg; + int dir; + + dir = npcm_sgpio_get_direction(gc, offset); + if (dir == 0) { + bank = offset_to_bank(offset); + + addr = bank_reg(gpio, bank, WRITE_DATA); + reg = ioread8(addr); + reg = !!(reg & GPIO_BIT(offset)); + } else { + offset -= gpio->nout_sgpio; + bank = offset_to_bank(offset); + + addr = bank_reg(gpio, bank, READ_DATA); + reg = ioread8(addr); + reg = !!(reg & GPIO_BIT(offset)); + } + + return reg; +} + +static void npcm_sgpio_setup_enable(struct npcm_sgpio *gpio, bool enable) +{ + u8 reg = 0; + + reg = ioread8(gpio->base + NPCM_IOXCTS); + reg = reg & ~NPCM_IOXCTS_RD_MODE; + reg = reg | NPCM_IOXCTS_RD_MODE_PERIODIC; + + if (enable) { + reg |= NPCM_IOXCTS_IOXIF_EN; + iowrite8(reg, gpio->base + NPCM_IOXCTS); + } else { + reg &= ~NPCM_IOXCTS_IOXIF_EN; + iowrite8(reg, gpio->base + NPCM_IOXCTS); + } +} + +static int npcm_sgpio_setup_clk(struct npcm_sgpio *gpio, + const struct npcm_clk_cfg *clk_cfg) +{ + unsigned long apb_freq; + u32 val; + u8 tmp; + int i; + + apb_freq = clk_get_rate(gpio->pclk); + tmp = ioread8(gpio->base + NPCM_IOXCFG1) & ~NPCM_IOXCFG1_SFT_CLK; + + for (i = 0; i < clk_cfg->cfg_opt; i++) { + val = apb_freq / clk_cfg->sft_clk[i]; + if ((NPCM_CLK_MHZ < val) && (i != 0) ) { + iowrite8(clk_cfg->clk_sel[i-1] | tmp, gpio->base + NPCM_IOXCFG1); + return 0; + } else if (i == (clk_cfg->cfg_opt-1) && (NPCM_CLK_MHZ > val)) { + iowrite8(clk_cfg->clk_sel[i] | tmp, gpio->base + NPCM_IOXCFG1); + return 0; + } + } + + return -EINVAL; +} + +static void npcm_sgpio_irq_init_valid_mask(struct gpio_chip *gc, + unsigned long *valid_mask, unsigned int ngpios) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + int n = gpio->nin_sgpio; + + /* input GPIOs in the high range */ + bitmap_set(valid_mask, gpio->nout_sgpio, n); + bitmap_clear(valid_mask, 0, gpio->nout_sgpio); +} + +static void npcm_sgpio_irq_set_mask(struct irq_data *d, bool set) +{ + const struct npcm_sgpio_bank *bank; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *addr; + unsigned int offset; + u16 reg, type; + u8 bit; + + irqd_to_npcm_sgpio_data(d, &gpio, &bank, &bit, &offset); + addr = bank_reg(gpio, bank, EVENT_CFG); + + raw_spin_lock_irqsave(&gpio->lock, flags); + + npcm_sgpio_setup_enable(gpio, false); + + reg = ioread16(addr); + if (set) { + reg &= ~(NPCM_IXOEVCFG_MASK << (bit * 2)); + } else { + type = gpio->int_type[offset]; + reg |= (type << (bit * 2)); + } + + iowrite16(reg, addr); + + npcm_sgpio_setup_enable(gpio, true); + + addr = bank_reg(gpio, bank, EVENT_STS); + reg = ioread8(addr); + reg |= BIT(bit); + iowrite8(reg, addr); + + raw_spin_unlock_irqrestore(&gpio->lock, flags); +} + +static void npcm_sgpio_irq_ack(struct irq_data *d) +{ + const struct npcm_sgpio_bank *bank; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *status_addr; + unsigned int offset; + u8 bit; + + irqd_to_npcm_sgpio_data(d, &gpio, &bank, &bit, &offset); + status_addr = bank_reg(gpio, bank, EVENT_STS); + raw_spin_lock_irqsave(&gpio->lock, flags); + iowrite8(BIT(bit), status_addr); + raw_spin_unlock_irqrestore(&gpio->lock, flags); +} + +static void npcm_sgpio_irq_mask(struct irq_data *d) +{ + npcm_sgpio_irq_set_mask(d, true); +} + +static void npcm_sgpio_irq_unmask(struct irq_data *d) +{ + npcm_sgpio_irq_set_mask(d, false); +} + +static int npcm_sgpio_set_type(struct irq_data *d, unsigned int type) +{ + const struct npcm_sgpio_bank *bank; + irq_flow_handler_t handler; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *addr; + unsigned int offset; + u16 reg, val; + u8 bit; + + irqd_to_npcm_sgpio_data(d, &gpio, &bank, &bit, &offset); + + switch (type & IRQ_TYPE_SENSE_MASK) { + case IRQ_TYPE_EDGE_BOTH: + val = NPCM_IXOEVCFG_BOTH; + handler = handle_edge_irq; + break; + case IRQ_TYPE_EDGE_RISING: + val = NPCM_IXOEVCFG_RISING; + handler = handle_edge_irq; + break; + case IRQ_TYPE_EDGE_FALLING: + val = NPCM_IXOEVCFG_FALLING; + handler = handle_edge_irq; + break; + case IRQ_TYPE_LEVEL_HIGH: + val = NPCM_IXOEVCFG_RISING; + handler = handle_level_irq; + break; + case IRQ_TYPE_LEVEL_LOW: + val = NPCM_IXOEVCFG_FALLING; + handler = handle_level_irq; + break; + default: + return -EINVAL; + } + + gpio->int_type[offset] = val; + + raw_spin_lock_irqsave(&gpio->lock, flags); + npcm_sgpio_setup_enable(gpio, false); + addr = bank_reg(gpio, bank, EVENT_CFG); + reg = ioread16(addr); + + reg |= (val << (bit * 2)); + + iowrite16(reg, addr); + npcm_sgpio_setup_enable(gpio, true); + raw_spin_unlock_irqrestore(&gpio->lock, flags); + + irq_set_handler_locked(d, handler); + + return 0; +} + +static void npcm_sgpio_irq_handler(struct irq_desc *desc) +{ + struct gpio_chip *gc = irq_desc_get_handler_data(desc); + struct irq_chip *ic = irq_desc_get_chip(desc); + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + unsigned int i, j, girq; + unsigned long reg; + + chained_irq_enter(ic, desc); + + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; + + reg = ioread8(bank_reg(gpio, bank, EVENT_STS)); + for_each_set_bit(j, ®, 8) { + girq = irq_find_mapping(gc->irq.domain, i * 8 + gpio->nout_sgpio + j); + generic_handle_irq(girq); + } + } + + chained_irq_exit(ic, desc); +} + +static const struct irq_chip sgpio_irq_chip = { + .name = "sgpio-irq", + .irq_ack = npcm_sgpio_irq_ack, + .irq_mask = npcm_sgpio_irq_mask, + .irq_unmask = npcm_sgpio_irq_unmask, + .irq_set_type = npcm_sgpio_set_type, + .flags = IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + +static int npcm_sgpio_setup_irqs(struct npcm_sgpio *gpio, + struct platform_device *pdev) +{ + int rc, i; + struct gpio_irq_chip *irq; + + rc = platform_get_irq(pdev, 0); + if (rc < 0) + return rc; + + gpio->irq = rc; + + npcm_sgpio_setup_enable(gpio, false); + + /* Disable IRQ and clear Interrupt status registers for all SGPIO Pins. */ + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; + + iowrite16(0x0000, bank_reg(gpio, bank, EVENT_CFG)); + iowrite8(0xff, bank_reg(gpio, bank, EVENT_STS)); + } + + irq = &gpio->chip.irq; + gpio_irq_chip_set_chip(irq, &sgpio_irq_chip); + irq->init_valid_mask = npcm_sgpio_irq_init_valid_mask; + irq->handler = handle_bad_irq; + irq->default_type = IRQ_TYPE_NONE; + irq->parent_handler = npcm_sgpio_irq_handler; + irq->parent_handler_data = gpio; + irq->parents = &gpio->irq; + irq->num_parents = 1; + + return 0; +} + +static unsigned int npcm750_SFT_CLK[] = { + 1024, 32, 8, 4, 3, 2, +}; + +static unsigned int npcm750_CLK_SEL[] = { + 0x00, 0x05, 0x07, 0x0C, 0x0D, 0x0E, +}; + +static unsigned int npcm845_SFT_CLK[] = { + 1024, 32, 16, 8, 4, +}; + +static unsigned int npcm845_CLK_SEL[] = { + 0x00, 0x05, 0x06, 0x07, 0x0C, +}; + +static struct npcm_clk_cfg npcm750_sgpio_pdata = { + .sft_clk = npcm750_SFT_CLK, + .clk_sel = npcm750_CLK_SEL, + .cfg_opt = 6, +}; + +static const struct npcm_clk_cfg npcm845_sgpio_pdata = { + .sft_clk = npcm845_SFT_CLK, + .clk_sel = npcm845_CLK_SEL, + .cfg_opt = 5, +}; + +static const struct of_device_id npcm_sgpio_of_table[] = { + { .compatible = "nuvoton,npcm750-sgpio", .data = &npcm750_sgpio_pdata, }, + { .compatible = "nuvoton,npcm845-sgpio", .data = &npcm845_sgpio_pdata, }, + {} +}; +MODULE_DEVICE_TABLE(of, npcm_sgpio_of_table); + +static int npcm_sgpio_probe(struct platform_device *pdev) +{ + struct npcm_sgpio *gpio; + const struct npcm_clk_cfg *clk_cfg; + int rc; + u32 nin_gpios, nout_gpios; + + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); + if (!gpio) + return -ENOMEM; + + gpio->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(gpio->base)) + return PTR_ERR(gpio->base); + + clk_cfg = device_get_match_data(&pdev->dev); + if (!clk_cfg) + return -EINVAL; + + rc = device_property_read_u32(&pdev->dev, "nuvoton,input-ngpios", &nin_gpios); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Could not read ngpios property\n"); + + rc = device_property_read_u32(&pdev->dev, "nuvoton,output-ngpios", &nout_gpios); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Could not read ngpios property\n"); + + gpio->nin_sgpio = nin_gpios; + gpio->nout_sgpio = nout_gpios; + if (gpio->nin_sgpio > MAX_NR_HW_SGPIO || gpio->nout_sgpio > MAX_NR_HW_SGPIO) { + dev_err(&pdev->dev, "Number of GPIOs exceeds the maximum of %d: input: %d output: %d\n", + MAX_NR_HW_SGPIO, nin_gpios, nout_gpios); + return -EINVAL; + } + + gpio->pclk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(gpio->pclk)) { + dev_err(&pdev->dev, "Could not get pclk\n"); + return PTR_ERR(gpio->pclk); + } + + rc = npcm_sgpio_setup_clk(gpio, clk_cfg); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Failed to setup clock\n"); + + raw_spin_lock_init(&gpio->lock); + gpio->chip.parent = &pdev->dev; + gpio->chip.ngpio = gpio->nin_sgpio + gpio->nout_sgpio; + gpio->chip.direction_input = npcm_sgpio_dir_in; + gpio->chip.direction_output = npcm_sgpio_dir_out; + gpio->chip.get_direction = npcm_sgpio_get_direction; + gpio->chip.get = npcm_sgpio_get; + gpio->chip.set = npcm_sgpio_set; + gpio->chip.label = dev_name(&pdev->dev); + gpio->chip.base = -1; + + rc = npcm_sgpio_init_port(gpio); + if (rc < 0) + return rc; + + rc = npcm_sgpio_setup_irqs(gpio, pdev); + if (rc < 0) + return rc; + + rc = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); + if (rc < 0) + return rc; + + npcm_sgpio_setup_enable(gpio, true); + + return 0; +} + +static struct platform_driver npcm_sgpio_driver = { + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = npcm_sgpio_of_table, + }, + .probe = npcm_sgpio_probe, +}; +module_platform_driver(npcm_sgpio_driver); + +MODULE_AUTHOR("Jim Liu "); +MODULE_AUTHOR("Joseph Liu "); +MODULE_DESCRIPTION("Nuvoton NPCM Serial GPIO Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 From pmenzel at molgen.mpg.de Tue Dec 12 18:00:34 2023 From: pmenzel at molgen.mpg.de (Paul Menzel) Date: Tue, 12 Dec 2023 08:00:34 +0100 Subject: [PATCH v9 1/3] dt-bindings: gpio: add NPCM sgpio driver bindings In-Reply-To: <20231212065147.3475413-2-jim.t90615@gmail.com> References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-2-jim.t90615@gmail.com> Message-ID: <72fe6f18-e3d7-4c74-9734-01a33dc8e100@molgen.mpg.de> Dear Jim, Thank you for your patch. Am 12.12.23 um 07:51 schrieb Jim Liu: > Add dt-bindings document for the Nuvoton NPCM7xx sgpio driver > > Signed-off-by: Jim Liu > Reviewed-by: Linus Walleij > Reviewed-by: Rob Herring As you seem to be employed by Nuvoton, should your company/work email be listed somehow, and even be used for the author address? > --- > Changes for v9: > - no changed > Changes for v8: > - no changed > Changes for v7: > - no changed > --- > .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++++++++++++++++++ > 1 file changed, 86 insertions(+) > create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml > > diff --git a/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml > new file mode 100644 > index 000000000000..84e0dbcb066c > --- /dev/null > +++ b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml > @@ -0,0 +1,86 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/gpio/nuvoton,sgpio.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Nuvoton SGPIO controller > + > +maintainers: > + - Jim LIU > + > +description: | > + This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. > + Nuvoton NPCM7xx SGPIO module is combine serial to parallel IC (HC595) s/is combine/combines a/ > + and parallel to serial IC (HC165), and use APB3 clock to control it. use*s* > + This interface has 4 pins (D_out , D_in, S_CLK, LDSH). Only one space before the (. > + NPCM7xx/NPCM8xx have two sgpio module each module can support up ? modules. Each module ? > + to 64 output pins,and up to 64 input pin, the pin is only for gpi or gpo. 1. Space after the comma. 2. 64 input pin*s > + GPIO pins have sequential, First half is gpo and second half is gpi. have sequential ?. > + GPIO pins can be programmed to support the following options > + - Support interrupt option for each input port and various interrupt > + sensitivity option (level-high, level-low, edge-high, edge-low) option*s* > + - ngpios is number of nuvoton,input-ngpios GPIO lines and nuvoton,output-ngpios GPIO lines. > + nuvoton,input-ngpios GPIO lines is only for gpi. s/is/are/ > + nuvoton,output-ngpios GPIO lines is only for gpo. s/is/are/ It?d be great if you mentioned the datasheet name and revision in the description. > + > +properties: > + compatible: > + enum: > + - nuvoton,npcm750-sgpio > + - nuvoton,npcm845-sgpio > + > + reg: > + maxItems: 1 > + > + gpio-controller: true > + > + '#gpio-cells': > + const: 2 > + > + interrupts: > + maxItems: 1 > + > + clocks: > + maxItems: 1 > + > + nuvoton,input-ngpios: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + The numbers of GPIO's exposed. GPIO lines is only for gpi. s/is/are/ > + minimum: 0 > + maximum: 64 > + > + nuvoton,output-ngpios: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > + The numbers of GPIO's exposed. GPIO lines is only for gpo. s/is/are/ > + minimum: 0 > + maximum: 64 > + > +required: > + - compatible > + - reg > + - gpio-controller > + - '#gpio-cells' > + - interrupts > + - nuvoton,input-ngpios > + - nuvoton,output-ngpios > + - clocks > + > +additionalProperties: false > + > +examples: > + - | > + #include > + #include > + gpio8: gpio at 101000 { > + compatible = "nuvoton,npcm750-sgpio"; > + reg = <0x101000 0x200>; > + clocks = <&clk NPCM7XX_CLK_APB3>; > + interrupts = ; > + gpio-controller; > + #gpio-cells = <2>; > + nuvoton,input-ngpios = <64>; > + nuvoton,output-ngpios = <64>; > + }; Reviewed-by: Paul Menzel Kind regards, Paul Menzel From jim.t90615 at gmail.com Tue Dec 12 19:41:32 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Tue, 12 Dec 2023 16:41:32 +0800 Subject: [PATCH v9 1/3] dt-bindings: gpio: add NPCM sgpio driver bindings In-Reply-To: <72fe6f18-e3d7-4c74-9734-01a33dc8e100@molgen.mpg.de> References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-2-jim.t90615@gmail.com> <72fe6f18-e3d7-4c74-9734-01a33dc8e100@molgen.mpg.de> Message-ID: Hi Paul Thanks for your review. I will modify it in the next version. Best regards, Jim On Tue, Dec 12, 2023 at 3:00?PM Paul Menzel wrote: > > Dear Jim, > > > Thank you for your patch. > > Am 12.12.23 um 07:51 schrieb Jim Liu: > > Add dt-bindings document for the Nuvoton NPCM7xx sgpio driver > > > > Signed-off-by: Jim Liu > > Reviewed-by: Linus Walleij > > Reviewed-by: Rob Herring > > As you seem to be employed by Nuvoton, should your company/work email be > listed somehow, and even be used for the author address? > > > --- > > Changes for v9: > > - no changed > > Changes for v8: > > - no changed > > Changes for v7: > > - no changed > > --- > > .../bindings/gpio/nuvoton,sgpio.yaml | 86 +++++++++++++++++++ > > 1 file changed, 86 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml > > > > diff --git a/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml > > new file mode 100644 > > index 000000000000..84e0dbcb066c > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml > > @@ -0,0 +1,86 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/gpio/nuvoton,sgpio.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Nuvoton SGPIO controller > > + > > +maintainers: > > + - Jim LIU > > + > > +description: | > > + This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. > > + Nuvoton NPCM7xx SGPIO module is combine serial to parallel IC (HC595) > > s/is combine/combines a/ > > > + and parallel to serial IC (HC165), and use APB3 clock to control it. > > use*s* > > > + This interface has 4 pins (D_out , D_in, S_CLK, LDSH). > > Only one space before the (. > > > + NPCM7xx/NPCM8xx have two sgpio module each module can support up > > ? modules. Each module ? > > > + to 64 output pins,and up to 64 input pin, the pin is only for gpi or gpo. > > 1. Space after the comma. > 2. 64 input pin*s > > > + GPIO pins have sequential, First half is gpo and second half is gpi. > > have sequential ?. > > > + GPIO pins can be programmed to support the following options > > + - Support interrupt option for each input port and various interrupt > > + sensitivity option (level-high, level-low, edge-high, edge-low) > > option*s* > > > + - ngpios is number of nuvoton,input-ngpios GPIO lines and nuvoton,output-ngpios GPIO lines. > > + nuvoton,input-ngpios GPIO lines is only for gpi. > > s/is/are/ > > > + nuvoton,output-ngpios GPIO lines is only for gpo. > > s/is/are/ > > It?d be great if you mentioned the datasheet name and revision in the > description. > > > + > > +properties: > > + compatible: > > + enum: > > + - nuvoton,npcm750-sgpio > > + - nuvoton,npcm845-sgpio > > + > > + reg: > > + maxItems: 1 > > + > > + gpio-controller: true > > + > > + '#gpio-cells': > > + const: 2 > > + > > + interrupts: > > + maxItems: 1 > > + > > + clocks: > > + maxItems: 1 > > + > > + nuvoton,input-ngpios: > > + $ref: /schemas/types.yaml#/definitions/uint32 > > + description: > > + The numbers of GPIO's exposed. GPIO lines is only for gpi. > > s/is/are/ > > > + minimum: 0 > > + maximum: 64 > > + > > + nuvoton,output-ngpios: > > + $ref: /schemas/types.yaml#/definitions/uint32 > > + description: > > + The numbers of GPIO's exposed. GPIO lines is only for gpo. > > s/is/are/ > > > + minimum: 0 > > + maximum: 64 > > + > > +required: > > + - compatible > > + - reg > > + - gpio-controller > > + - '#gpio-cells' > > + - interrupts > > + - nuvoton,input-ngpios > > + - nuvoton,output-ngpios > > + - clocks > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > + #include > > + #include > > + gpio8: gpio at 101000 { > > + compatible = "nuvoton,npcm750-sgpio"; > > + reg = <0x101000 0x200>; > > + clocks = <&clk NPCM7XX_CLK_APB3>; > > + interrupts = ; > > + gpio-controller; > > + #gpio-cells = <2>; > > + nuvoton,input-ngpios = <64>; > > + nuvoton,output-ngpios = <64>; > > + }; > > Reviewed-by: Paul Menzel > > > Kind regards, > > Paul Menzel From tmaimon77 at gmail.com Tue Dec 12 21:07:02 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Tue, 12 Dec 2023 12:07:02 +0200 Subject: [PATCH v2 2/3] soc: nuvoton: add configuration menu In-Reply-To: <20231212100703.3374555-1-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> Message-ID: <20231212100703.3374555-3-tmaimon77@gmail.com> Add menu configuration to Nuvoton SoC drivers. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index df46182088ec..d5102f5f0c28 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -menuconfig WPCM450_SOC + +menu "NUVOTON SoC drivers" + +config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 select SOC_BUS @@ -9,3 +12,5 @@ menuconfig WPCM450_SOC This driver provides information such as the SoC model and revision. + +endmenu -- 2.34.1 From tmaimon77 at gmail.com Tue Dec 12 21:07:00 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Tue, 12 Dec 2023 12:07:00 +0200 Subject: [PATCH v2 0/3] soc: add NPCM BPC driver support Message-ID: <20231212100703.3374555-1-tmaimon77@gmail.com> This patch set adds BIOS Post code (BPC) support for the Nuvoton NPCM Baseboard Management Controller (BMC). Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O addresses written by the host on the bus, the capture data stored in 128-word FIFO. NPCM BPC can support capture double words. The NPCM BPC driver tested on NPCM750 Olympus board. Tomer Maimon (3): dt-bindings: soc: nuvoton: Add NPCM BPC soc: nuvoton: add configuration menu soc: nuvoton: add NPCM BPC driver .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 63 +++ drivers/soc/nuvoton/Kconfig | 16 +- drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 388 ++++++++++++++++++ 4 files changed, 467 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml create mode 100644 drivers/soc/nuvoton/npcm-bpc.c -- 2.34.1 From tmaimon77 at gmail.com Tue Dec 12 21:07:01 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Tue, 12 Dec 2023 12:07:01 +0200 Subject: [PATCH v2 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC In-Reply-To: <20231212100703.3374555-1-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> Message-ID: <20231212100703.3374555-2-tmaimon77@gmail.com> Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC). The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus. Signed-off-by: Tomer Maimon --- .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml diff --git a/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file mode 100644 index 000000000000..30033cdac8f5 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton BMC NPCM BIOS Post Code (bpc) controller + +maintainers: + - Tomer Maimon + +description: + Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O + addresses written by the host on the bus, the capture data stored in + 128-word FIFO. + + NPCM BPC supports capture double words, when using capture + double word only I/O address 1 is monitored. + +properties: + compatible: + enum: + - nuvoton,npcm750-bpc + - nuvoton,npcm845-bpc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + nuvoton,monitor-ports: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Contain monitor I/O addresses on the bus, at least one monitor I/O + address required. + + nuvoton,bpc-en-dwcapture: + description: + If present, Enable FIFO capture of the DWord address according to + one address setting. + type: boolean + +required: + - compatible + - reg + - interrupts + - nuvoton,monitor-ports + +additionalProperties: false + +examples: + - | + #include + #include + + bpc: bpc at f0007040 { + compatible = "nuvoton,npcm750-bpc"; + reg = <0xf0007040 0x20>; + interrupts = ; + nuvoton,monitor-ports = <0x80>; + }; +... -- 2.34.1 From tmaimon77 at gmail.com Tue Dec 12 21:07:03 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Tue, 12 Dec 2023 12:07:03 +0200 Subject: [PATCH v2 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <20231212100703.3374555-1-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> Message-ID: <20231212100703.3374555-4-tmaimon77@gmail.com> Add Nuvoton BMC NPCM BIOS post code (BPC) driver. The NPCM BPC monitoring two configurable I/O address written by the host on the bus. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 9 + drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 388 +++++++++++++++++++++++++++++++++ 3 files changed, 398 insertions(+) create mode 100644 drivers/soc/nuvoton/npcm-bpc.c diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index d5102f5f0c28..ebd162633942 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -2,6 +2,15 @@ menu "NUVOTON SoC drivers" +config NPCM_BPC + tristate "NPCM BIOS Post Code support" + depends on (ARCH_NPCM || COMPILE_TEST) + help + Provides NPCM driver to control the BIOS Post Code + interface which allows the BMC to monitor and save + the data written by the host to an arbitrary I/O port, + the BPC is connected to the host thourgh LPC or eSPI bus. + config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 diff --git a/drivers/soc/nuvoton/Makefile b/drivers/soc/nuvoton/Makefile index e30317b4e829..c6c96079c6e9 100644 --- a/drivers/soc/nuvoton/Makefile +++ b/drivers/soc/nuvoton/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_NPCM_BPC) += npcm-bpc.o obj-$(CONFIG_WPCM450_SOC) += wpcm450-soc.o diff --git a/drivers/soc/nuvoton/npcm-bpc.c b/drivers/soc/nuvoton/npcm-bpc.c new file mode 100644 index 000000000000..149b05f0ac77 --- /dev/null +++ b/drivers/soc/nuvoton/npcm-bpc.c @@ -0,0 +1,388 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2020 Nuvoton Technology corporation. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEVICE_NAME "npcm-bpc" + +#define NUM_BPC_CHANNELS 2 +#define DW_PAD_SIZE 3 + +/* BIOS POST Code FIFO Registers */ +#define NPCM_BPCFA2L_REG 0x2 //BIOS POST Code FIFO Address 2 LSB +#define NPCM_BPCFA2M_REG 0x4 //BIOS POST Code FIFO Address 2 MSB +#define NPCM_BPCFEN_REG 0x6 //BIOS POST Code FIFO Enable +#define NPCM_BPCFSTAT_REG 0x8 //BIOS POST Code FIFO Status +#define NPCM_BPCFDATA_REG 0xA //BIOS POST Code FIFO Data +#define NPCM_BPCFMSTAT_REG 0xC //BIOS POST Code FIFO Miscellaneous Status +#define NPCM_BPCFA1L_REG 0x10 //BIOS POST Code FIFO Address 1 LSB +#define NPCM_BPCFA1M_REG 0x12 //BIOS POST Code FIFO Address 1 MSB + +/* BIOS register data */ +#define FIFO_IOADDR1_ENABLE 0x80 +#define FIFO_IOADDR2_ENABLE 0x40 + +/* BPC interface package and structure definition */ +#define BPC_KFIFO_SIZE 0x400 + +/* BPC register data */ +#define FIFO_DATA_VALID 0x80 +#define FIFO_OVERFLOW 0x20 +#define FIFO_READY_INT_ENABLE 0x8 +#define FIFO_DWCAPTURE 0x4 +#define FIFO_ADDR_DECODE 0x1 + +/* Host Reset */ +#define HOST_RESET_INT_ENABLE 0x10 +#define HOST_RESET_CHANGED 0x40 + +struct npcm_bpc_channel { + struct npcm_bpc *data; + struct kfifo fifo; + wait_queue_head_t wq; + bool host_reset; + struct miscdevice miscdev; +}; + +struct npcm_bpc { + void __iomem *base; + struct device *dev; + int irq; + bool en_dwcap; + struct npcm_bpc_channel ch[NUM_BPC_CHANNELS]; +}; + +static struct npcm_bpc_channel *npcm_file_to_ch(struct file *file) +{ + return container_of(file->private_data, struct npcm_bpc_channel, + miscdev); +} + +static ssize_t npcm_bpc_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + struct npcm_bpc *bpc = chan->data; + unsigned int copied; + int cond_size = 1; + int ret = 0; + + if (bpc->en_dwcap) + cond_size = 3; + + if (kfifo_len(&chan->fifo) < cond_size) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible + (chan->wq, kfifo_len(&chan->fifo) > cond_size); + if (ret == -ERESTARTSYS) + return -EINTR; + } + + ret = kfifo_to_user(&chan->fifo, buffer, count, &copied); + + return ret ? ret : copied; +} + +static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + __poll_t mask = 0; + + poll_wait(file, &chan->wq, pt); + if (!kfifo_is_empty(&chan->fifo)) + mask |= POLLIN; + + if (chan->host_reset) { + mask |= POLLHUP; + chan->host_reset = false; + } + + return mask; +} + +static const struct file_operations npcm_bpc_fops = { + .owner = THIS_MODULE, + .read = npcm_bpc_read, + .poll = npcm_bpc_poll, + .llseek = noop_llseek, +}; + +static irqreturn_t npcm_bpc_irq(int irq, void *arg) +{ + struct npcm_bpc *bpc = arg; + u8 fifo_st, host_st, data; + bool isr_flag = false; + u8 last_addr_bit = 0; + u8 padzero[3] = {0}; + u8 addr_index = 0; + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + while (FIFO_DATA_VALID & fifo_st) { + /* If dwcapture enabled only channel 0 (FIFO 0) used */ + if (!bpc->en_dwcap) + addr_index = fifo_st & FIFO_ADDR_DECODE; + else + last_addr_bit = fifo_st & FIFO_ADDR_DECODE; + + /* Read data from FIFO to clear interrupt */ + data = ioread8(bpc->base + NPCM_BPCFDATA_REG); + if (kfifo_is_full(&bpc->ch[addr_index].fifo)) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_put(&bpc->ch[addr_index].fifo, data); + if (fifo_st & FIFO_OVERFLOW) + dev_warn(bpc->dev, "BIOS Post Codes FIFO Overflow\n"); + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + if (bpc->en_dwcap && last_addr_bit) { + if ((fifo_st & FIFO_ADDR_DECODE) || + ((FIFO_DATA_VALID & fifo_st) == 0)) { + while (kfifo_avail(&bpc->ch[addr_index].fifo) < DW_PAD_SIZE) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_in(&bpc->ch[addr_index].fifo, + padzero, DW_PAD_SIZE); + } + } + isr_flag = true; + } + + host_st = ioread8(bpc->base + NPCM_BPCFMSTAT_REG); + if (host_st & HOST_RESET_CHANGED) { + iowrite8(HOST_RESET_CHANGED, + bpc->base + NPCM_BPCFMSTAT_REG); + bpc->ch[addr_index].host_reset = true; + isr_flag = true; + } + + if (isr_flag) { + wake_up_interruptible(&bpc->ch[addr_index].wq); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int npcm_bpc_config_irq(struct npcm_bpc *bpc, + struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int rc; + + bpc->irq = platform_get_irq(pdev, 0); + if (bpc->irq < 0) { + dev_err(dev, "get IRQ failed\n"); + return bpc->irq; + } + + rc = devm_request_irq(dev, bpc->irq, + npcm_bpc_irq, IRQF_SHARED, + DEVICE_NAME, bpc); + if (rc < 0) { + dev_warn(dev, "Unable to request IRQ %d\n", bpc->irq); + return rc; + } + + return 0; +} + +static int npcm_enable_bpc(struct npcm_bpc *bpc, struct device *dev, + int channel, u16 host_port) +{ + u8 addr_en, reg_en; + int err; + + init_waitqueue_head(&bpc->ch[channel].wq); + + err = kfifo_alloc(&bpc->ch[channel].fifo, BPC_KFIFO_SIZE, + GFP_KERNEL); + if (err) + return err; + + bpc->ch[channel].miscdev.minor = MISC_DYNAMIC_MINOR; + bpc->ch[channel].miscdev.name = + devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME, channel); + bpc->ch[channel].miscdev.fops = &npcm_bpc_fops; + bpc->ch[channel].miscdev.parent = dev; + err = misc_register(&bpc->ch[channel].miscdev); + if (err) + return err; + + bpc->ch[channel].data = bpc; + bpc->ch[channel].host_reset = false; + + /* Enable host snoop channel at requested port */ + switch (channel) { + case 0: + addr_en = FIFO_IOADDR1_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA1L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA1M_REG); + break; + case 1: + addr_en = FIFO_IOADDR2_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA2L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA2M_REG); + break; + default: + return -EINVAL; + } + + if (bpc->en_dwcap) + addr_en = FIFO_DWCAPTURE; + + /* + * Enable FIFO Ready Interrupt, FIFO Capture of I/O addr, + * and Host Reset + */ + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en | addr_en | FIFO_READY_INT_ENABLE | + HOST_RESET_INT_ENABLE, bpc->base + NPCM_BPCFEN_REG); + + return 0; +} + +static void npcm_disable_bpc(struct npcm_bpc *bpc, int channel) +{ + u8 reg_en; + + switch (channel) { + case 0: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + if (bpc->en_dwcap) + iowrite8(reg_en & ~FIFO_DWCAPTURE, + bpc->base + NPCM_BPCFEN_REG); + else + iowrite8(reg_en & ~FIFO_IOADDR1_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + case 1: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en & ~FIFO_IOADDR2_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + default: + return; + } + + if (!(reg_en & (FIFO_IOADDR1_ENABLE | FIFO_IOADDR2_ENABLE))) + iowrite8(reg_en & + ~(FIFO_READY_INT_ENABLE | HOST_RESET_INT_ENABLE), + bpc->base + NPCM_BPCFEN_REG); + + kfifo_free(&bpc->ch[channel].fifo); + misc_deregister(&bpc->ch[channel].miscdev); +} + +static int npcm_bpc_probe(struct platform_device *pdev) +{ + struct npcm_bpc *bpc; + struct device *dev; + u32 port; + int err; + + dev = &pdev->dev; + + bpc = devm_kzalloc(dev, sizeof(*bpc), GFP_KERNEL); + if (!bpc) + return -ENOMEM; + + bpc->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bpc->base)) + return PTR_ERR(bpc->base); + + dev_set_drvdata(&pdev->dev, bpc); + + err = of_property_read_u32_index(dev->of_node, "nuvoton,monitor-ports", + 0, &port); + if (err) { + dev_err(dev, "no monitor ports configured\n"); + return -ENODEV; + } + + bpc->en_dwcap = + of_property_read_bool(dev->of_node, "nuvoton,bpc-en-dwcapture"); + + bpc->dev = dev; + + err = npcm_bpc_config_irq(bpc, pdev); + if (err) + return err; + + err = npcm_enable_bpc(bpc, dev, 0, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 0 failed\n"); + return err; + } + + /* + * Configuration of second BPC channel port is optional + * Double-Word Capture ignoring address 2 + */ + if (!bpc->en_dwcap) { + if (of_property_read_u32_index(dev->of_node, + "nuvoton,monitor-ports", 1, + &port) == 0) { + err = npcm_enable_bpc(bpc, dev, 1, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 1 failed, disable I/O port 0\n"); + npcm_disable_bpc(bpc, 0); + return err; + } + } + } + + pr_info("NPCM BIOS Post Code probe\n"); + + return err; +} + +static int npcm_bpc_remove(struct platform_device *pdev) +{ + struct npcm_bpc *bpc = dev_get_drvdata(&pdev->dev); + u8 reg_en; + + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + + if (reg_en & FIFO_IOADDR1_ENABLE) + npcm_disable_bpc(bpc, 0); + if (reg_en & FIFO_IOADDR2_ENABLE) + npcm_disable_bpc(bpc, 1); + + return 0; +} + +static const struct of_device_id npcm_bpc_match[] = { + { .compatible = "nuvoton,npcm750-bpc" }, + { .compatible = "nuvoton,npcm845-bpc" }, + { }, +}; + +static struct platform_driver npcm_bpc_driver = { + .driver = { + .name = DEVICE_NAME, + .of_match_table = npcm_bpc_match, + }, + .probe = npcm_bpc_probe, + .remove = npcm_bpc_remove, +}; + +module_platform_driver(npcm_bpc_driver); + +MODULE_DEVICE_TABLE(of, npcm_bpc_match); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_DESCRIPTION("NPCM BIOS post code monitoring device driver"); -- 2.34.1 From fancer.lancer at gmail.com Wed Dec 13 00:52:15 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 12 Dec 2023 16:52:15 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: Hi Andrew, Russell Sorry for the delay with response. I had to refresh my understanding of the series since it was created sometime ago and I already managed to forget some of its aspects (particularly regarding the MDIO-bus PHY-mask semantics). On Tue, Dec 05, 2023 at 02:50:58PM +0000, Russell King (Oracle) wrote: > On Tue, Dec 05, 2023 at 02:52:24PM +0100, Andrew Lunn wrote: > > On Tue, Dec 05, 2023 at 02:31:41PM +0300, Serge Semin wrote: > > > On Tue, Dec 05, 2023 at 10:49:47AM +0000, Russell King (Oracle) wrote: > > > > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > > > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > > > > or explicitly registered in the MDIO subsystem by means of the > > > > > mdiobus_register_board_info() method there is no point in creating the > > > > > dummy MDIO device instance in order to get the DW XPCS handler since the > > > > > MDIO core subsystem will create the device during the MDIO bus > > > > > registration procedure. > > > > > > > > > > > Please reword this overly long sentence. > > > > > > Ok. > > > > > > > > > > > If they're left unmasked, what prevents them being created as PHY > > > > devices? > > > > > > Not sure I fully get what you meant. If they are left unmasked the > > > MDIO-device descriptor will be created by the MDIO subsystem anyway. > > > What the point in creating another one? > > > > Saying what Russell said, in a different way: > > > > /* > > * Return true if the child node is for a phy. It must either: > > * o Compatible string of "ethernet-phy-idX.X" > > * o Compatible string of "ethernet-phy-ieee802.3-c45" > > * o Compatible string of "ethernet-phy-ieee802.3-c22" > > * o In the white list above (and issue a warning) > > * o No compatibility string > > * > > * A device which is not a phy is expected to have a compatible string > > * indicating what sort of device it is. > > */ > > bool of_mdiobus_child_is_phy(struct device_node *child) > > > > So when walking the bus, if a node is found which fits these criteria, > > its assumed to be a PHY. > > > > Anything on the MDIO bus which is not a PHY needs to use a compatible. > > Right. I'd actually forgotten about the firmware-based walking, and > was thinking more of the non-firmware bus scanning as the commit > message was talking about being _unmasked_ and the only mask we have > is bus->phy_mask. Back then when I was working on the series and up until last week I had thought that having a device unmasked in mii_bus->phy_mask was a correct way to do for _any_ device including our DW XPCS (which BTW looks like a normal C45 PHY and if synthesized with a PMA attached could be passed to be handled by the PHY subsystem). Can't remember why exactly I came to that thought, but likely it was due to finding out examples of having mii_bus->phy_mask uninitialized in some of the PCS use-cases, like in drivers/net/dsa/ocelot/felix_vsc9959.c (but in case of DW XPCS the mask is always set indeed). Anyway obviously I was wrong and PHY-device is supposed to be created only if a device is actual PHY and handled by the PHY subsystem drivers. So the correct ways to create PHY MDIO-devices are: 1. Call mdiobus_register() with PHY-addresses unmasked 2. Call of_mdiobus_register() for a DT-node with sub-nodes for which of_mdiobus_child_is_phy() returns true. and the correct ways to create non-PHY MDIO-devices are: 1. Call mdiobus_register() with non-PHY-addresses masked and have those non-PHY device registered by mdiobus_register_board_info() beforehand. 2. Call of_mdiobus_register() with DT sub-nodes having specific compatible string (based on the of_mdiobus_child_is_phy() semantics). Only in case of having a non-PHY device registered it's allowed to use it in in non-PHY MDIO driver, like PCS, etc. Right? Please correct me if I am wrong or miss something. > > It seems to me that this is yet another case of a really confusing > commit message making review harder than it needs to be. >From the perspective described above the patch log is indeed partly wrong. Sorry about that. I shouldn't have mentioned the mask at all but instead just listed two use-cases of creating the non-PHY MDIO-devices. I'll fix that in v2. -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! > From fancer.lancer at gmail.com Wed Dec 13 02:26:16 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 12 Dec 2023 18:26:16 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 02:54:00PM +0000, Russell King (Oracle) wrote: > On Tue, Dec 05, 2023 at 01:46:44PM +0000, Russell King (Oracle) wrote: > > For your use case, it would be: > > > > mdiodev = bus->mdio_map[addr]; > > By the way, this should be: > > mdiodev = mdiobus_find_device(bus, addr); > if (!mdiodev) > return ERR_PTR(-ENODEV); > > to avoid a layering violation. I would have used in the first place if it was externally visible, but it's defined as static. Do you suggest to make it global or ... > At some point, we should implement > mdiobus_get_mdiodev() which also deals with the refcount. ... create mdiobus_get_mdiodev() instead? * Note in the commit message I mentioned that having a getter would be * better than directly touching the mii_bus instance guts. -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From linux at armlinux.org.uk Wed Dec 13 06:06:46 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Tue, 12 Dec 2023 19:06:46 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 12, 2023 at 06:26:16PM +0300, Serge Semin wrote: > I would have used in the first place if it was externally visible, but > it's defined as static. Do you suggest to make it global or ... That would be one option - I didn't make it visible when I introduced it beacuse there were no users for it. > > At some point, we should implement > > mdiobus_get_mdiodev() which also deals with the refcount. > > ... create mdiobus_get_mdiodev() instead? > > * Note in the commit message I mentioned that having a getter would be > * better than directly touching the mii_bus instance guts. What I'm thinking is: /** * mdiobus_get_mdiodev() - get a mdiodev for the specified bus * @bus: mii_bus to get mdio device from * @addr: mdio address of mdio device * * Return the struct mdio_device attached to the MII bus @bus at MDIO * address @addr. On success, the refcount on the device will be * increased, which must be dropped using mdio_device_put(), and the * mdio device returned. Otherwise, returns NULL. */ struct mdio_device *mdiobus_get_mdiodev(struct mii_bus *bus, int addr) { struct mdio_device *mdiodev; mdiodev = mdiobus_find_device(bus, addr); if (mdiodev) get_device(&mdiodev->dev); return mdiodev; } EXPORT_SYMBOL(mdiobus_get_mdiodev); should do it, and will hold a reference on the mdiodev structure (which won't be freed) and also on the mii_bus (since this device is a child of the bus device, the parent can't be released until the child has been, so struct mii_bus should at least stay around.) What would help the "the bus driver has been unbound" situation is if we took the mdio_lock on the bus, and then set the {read,write}{,_c45} functions to dummy stubs when the bus is being unregistered which then return e.g. -ENXIO. That will probably make unbinding/unloading all MDIO bus drivers safe from kernel oops, although phylib will spit out a non-useful backtrace if it tries an access. I don't think there's much which can be done about that - I did propose a patch to change that behaviour but apparently folk like having it! It isn't perfect - it's racy, but then accessing mdio_map[] is inherently racy due to no locking with mdiobus_.*register_device(). At least if we have everyone using a proper getter function rather than directly fiddling with bus->mdio_map[]. We only have one driver that accesses it directly at the moment (mscc_ptp): dev = phydev->mdio.bus->mdio_map[vsc8531->ts_base_addr]; phydev = container_of(dev, struct phy_device, mdio); return phydev->priv; and that should really be using mdiobus_get_phy(). -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From patrick at stwcx.xyz Wed Dec 13 08:26:04 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Tue, 12 Dec 2023 15:26:04 -0600 Subject: [PATCH dev-5.6 1/3] net/ncsi: Simplify Kconfig/dts control flow In-Reply-To: References: <20231205234843.4013767-1-patrick@stwcx.xyz> Message-ID: Joel, I realized I used "5.6" as the prefix on these when I meant "6.6". Can these be picked up as is or do you need me to resent? On Tue, Dec 05, 2023 at 07:00:25PM -0600, Patrick Williams wrote: > On Tue, Dec 05, 2023 at 05:48:41PM -0600, Patrick Williams wrote: > > (cherry picked from commit c797ce168930ce3d62a9b7fc4d7040963ee6a01e) > > These patches were cherry-picked from the net-next tree and thus are > tentatively going into the 6.8 tree. I've applied them onto our 6.5 > tree, but they should apply cleanly to 6.6 also. > > -- > Patrick Williams -- Patrick Williams From patrick at stwcx.xyz Wed Dec 13 08:43:06 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Tue, 12 Dec 2023 15:43:06 -0600 Subject: [PATCH linux dev-6.5 v4 0/2] LTC4286 and LTC4287 driver support In-Reply-To: References: <20231108082019.1601366-1-Delphine_CC_Chiu@Wiwynn.com> Message-ID: Hello Joel, On Tue, Dec 12, 2023 at 12:42:18PM +1030, Joel Stanley wrote: > I have some > new rules for getting the patches merged into openbmc: Can you please update this wiki with what your current expectations are then because these are not obviously reflected: https://github.com/openbmc/linux/wiki/DevelopmentProcess > 1. Do not send them for backporting to the dev-6.6 branch until they > have been reviewed upstream. This means you have Reviewed-by or > Acked-by tags on at least a majority of the patches in a series before > you send them to the openbmc list. > 2. Find reviewers for your upstream patches. Get other Facebook > employees, get other openbmc contributors to review your patches. A > good way to encourage others to review your patches is to first review > thiers. The submitters here are not Facebook employees (nit: there is also no such thing as the company changed names 2 years ago now), but they are doing work partially on behalf of Meta as their company is partnering with us to develop new systems. In this case, I don't think review has been an issue since Guenter applied v7 to his tree. > 3. When you do send the patches for backporting, include a > justification in the cover letter for why they should be backported. > For example: "These patches are merged upstream" or "the changes under > active review, but we wish to have them in the openbmc tree because it > has been ongoing for more than two weeks". It would be nice for the wiki to give clear unbiased criteria here. Currently it says: Patches for pre-upstream inclusion ... should be at least of a level approximately ready to submit upstream. This implies, by my reading, that any commit sent upstream can in parallel be sent to our 'dev-*' branches, since that is a stronger criteria than you've listed. Anyone can carry patches in their own downstream trees, so it isn't obvious to me when it is deemed beneficial and not a burden to also request a backport to the openbmc/linux branches. I get the impression that our backports requests are more on the burden end of the spectrum. > Your latest upstream patchset produces a large number of warnings when > I applied it to the 6.7-rc1 tree. This shows you are not compiling > your changes before submitting. > > Please engage with me and the other developers on this issue so we can > help each other get the changes up to scratch and merged. > > Cheers, > > Joel -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From fancer.lancer at gmail.com Wed Dec 13 11:01:45 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Wed, 13 Dec 2023 03:01:45 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 05, 2023 at 01:46:44PM +0000, Russell King (Oracle) wrote: > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > or explicitly registered in the MDIO subsystem by means of the > > mdiobus_register_board_info() method there is no point in creating the > > dummy MDIO device instance in order to get the DW XPCS handler since the > > MDIO core subsystem will create the device during the MDIO bus > > registration procedure. All what needs to be done is to just reuse the > > MDIO-device instance available in the mii_bus.mdio_map array (using some > > getter for it would look better though). It shall prevent the XPCS devices > > been accessed over several MDIO-device instances. > > > > Note since the MDIO-device instance might be retrieved from the MDIO-bus > > map array its reference counter shall be increased. If the MDIO-device > > instance is created in the xpcs_create_mdiodev() method its reference > > counter will be already increased. So there is no point in toggling the > > reference counter in the xpcs_create() function. Just drop it from there. > > > > Signed-off-by: Serge Semin > > --- > > drivers/net/pcs/pcs-xpcs.c | 26 +++++++++++++------------- > > 1 file changed, 13 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c > > index 2850122f354a..a53376472394 100644 > > --- a/drivers/net/pcs/pcs-xpcs.c > > +++ b/drivers/net/pcs/pcs-xpcs.c > > @@ -1376,7 +1376,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > > if (!xpcs) > > return ERR_PTR(-ENOMEM); > > > > - mdio_device_get(mdiodev); > > xpcs->mdiodev = mdiodev; > > > > xpcs_id = xpcs_get_id(xpcs); > > @@ -1417,7 +1416,6 @@ static struct dw_xpcs *xpcs_create(struct mdio_device *mdiodev, > > ret = -ENODEV; > > > > out: > > - mdio_device_put(mdiodev); > > kfree(xpcs); > > > > return ERR_PTR(ret); > > The above two hunks are a completely Unnecessary change. > > > @@ -1437,19 +1435,21 @@ struct dw_xpcs *xpcs_create_mdiodev(struct mii_bus *bus, int addr, > > struct mdio_device *mdiodev; > > struct dw_xpcs *xpcs; > > > > - mdiodev = mdio_device_create(bus, addr); > > - if (IS_ERR(mdiodev)) > > - return ERR_CAST(mdiodev); > > + if (addr >= PHY_MAX_ADDR) > > + return ERR_PTR(-EINVAL); > > > > - xpcs = xpcs_create(mdiodev, interface); > > + if (mdiobus_is_registered_device(bus, addr)) { > > + mdiodev = bus->mdio_map[addr]; > > + mdio_device_get(mdiodev); > > This is fine - taking a reference on the mdiodev you've got from > somewhere else is the right thing to do. > > > + } else { > > + mdiodev = mdio_device_create(bus, addr); > > + if (IS_ERR(mdiodev)) > > + return ERR_CAST(mdiodev); > > + } > > > > - /* xpcs_create() has taken a refcount on the mdiodev if it was > > - * successful. If xpcs_create() fails, this will free the mdio > > - * device here. In any case, we don't need to hold our reference > > - * anymore, and putting it here will allow mdio_device_put() in > > - * xpcs_destroy() to automatically free the mdio device. > > - */ > > - mdio_device_put(mdiodev); > > + xpcs = xpcs_create(mdiodev, interface); > > + if (IS_ERR(xpcs)) > > + mdio_device_put(mdiodev); > > Without the change to xpcs_create() you don't need this change - and > this is why I say you don't understand refcounting. > > The point here is that the refcounting management is in each function > where references are gained or lost. > > xpcs_create() creates a new reference to the mdiodev by storing it in > the dw_xpcs structure. Therefore, it takes a reference to the mdiodev. > If something fails, it drops that reference to restore the refcount > as it was on function entry. > > xpcs_create_mdiodev() as it originally stood creates the mdiodev from > the bus/address, and then passes that to xpcs_create(). Once > xpcs_create() has finished its work (irrespective of whether it was > successful or not) we're done with the mdiodev in this function, so > the reference is _always_ put. Can't deny now I fully understood the whole concept indeed. It was the first time I met the double refcount management in a single place. My understanding was that it was enough to increment the counter once, when a driver got a pointer from somewhere else (like another subsystem) and decrement it after it's not used for sure. From that perspective getting a device in xpcs_create_mdiodev(), putting it in the cleanup-on-error path and in xpcs_destroy() was supposed to be enough. You say that it's required to manage the refcounting twice: when we get the reference from some external place and internally when the reference is stored in the XPCS descriptor. What's the point in such redundancy with the internal ref-counting if we know that the pointer can be safely stored and utilized afterwards? Better maintainability? Is it due to having the object retrieval and storing implemented in different functions? While at it if you happen to know an answer could you please also clarify the next question. None of the ordinary platform/PCI/USB/hwmon/etc drivers I've been working with managed refcounting on storing a passed to probe() device pointer in the private driver data. Is it wrong not doing that? Should the drivers call get_device() or it's derivatives in probe() if the respective object is stored in the driver data? If they shouldn't since the ref is already counted by the bus-specific probe() methods, then what makes the DW XPCS create/destroy methods special to have the double ref-counting utilized there? > > For your use case, it would be: > > mdiodev = bus->mdio_map[addr]; > mdio_device_get(mdiodev); > > xpcs = xpcs_create(mdiodev, interface); > > mdio_device_put(mdiodev); > > return xpcs; > > which illustrates this point - we get a reference to the mdiodev by > reading it from the array. We do something (calling xpcs_create) > with it. If that something was successful, it takes its own refcount > otherwise leaves it as-is. We're then done with the mdiodev so we > drop the refcount we took. I do understand the way the refcount management works in your implementation. It's just hard to figure out the reason of having the second get/set pair utilized for the internal reference. Anyway thanks for providing a very detailed comment and in advance for answering my questions. -Serge(y) > > There is no need to make the code more complicated by changing this, > so I regard the refcount changes in this patch to be wrong. > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From lkp at intel.com Wed Dec 13 11:48:00 2023 From: lkp at intel.com (kernel test robot) Date: Wed, 13 Dec 2023 08:48:00 +0800 Subject: [PATCH v2 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <20231212100703.3374555-4-tmaimon77@gmail.com> References: <20231212100703.3374555-4-tmaimon77@gmail.com> Message-ID: <202312130836.kt5QMxGM-lkp@intel.com> Hi Tomer, kernel test robot noticed the following build warnings: [auto build test WARNING on soc/for-next] [also build test WARNING on robh/for-next linus/master v6.7-rc5 next-20231212] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Tomer-Maimon/dt-bindings-soc-nuvoton-Add-NPCM-BPC/20231212-181115 base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next patch link: https://lore.kernel.org/r/20231212100703.3374555-4-tmaimon77%40gmail.com patch subject: [PATCH v2 3/3] soc: nuvoton: add NPCM BPC driver config: arm64-randconfig-r112-20231213 (https://download.01.org/0day-ci/archive/20231213/202312130836.kt5QMxGM-lkp at intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce: (https://download.01.org/0day-ci/archive/20231213/202312130836.kt5QMxGM-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312130836.kt5QMxGM-lkp at intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/soc/nuvoton/npcm-bpc.c:105:22: sparse: sparse: invalid assignment: |= >> drivers/soc/nuvoton/npcm-bpc.c:105:22: sparse: left side has type restricted __poll_t >> drivers/soc/nuvoton/npcm-bpc.c:105:22: sparse: right side has type int drivers/soc/nuvoton/npcm-bpc.c:108:22: sparse: sparse: invalid assignment: |= drivers/soc/nuvoton/npcm-bpc.c:108:22: sparse: left side has type restricted __poll_t drivers/soc/nuvoton/npcm-bpc.c:108:22: sparse: right side has type int vim +105 drivers/soc/nuvoton/npcm-bpc.c 97 98 static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt) 99 { 100 struct npcm_bpc_channel *chan = npcm_file_to_ch(file); 101 __poll_t mask = 0; 102 103 poll_wait(file, &chan->wq, pt); 104 if (!kfifo_is_empty(&chan->fifo)) > 105 mask |= POLLIN; 106 107 if (chan->host_reset) { 108 mask |= POLLHUP; 109 chan->host_reset = false; 110 } 111 112 return mask; 113 } 114 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From tmaimon77 at gmail.com Wed Dec 13 20:44:21 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 11:44:21 +0200 Subject: [PATCH v2 0/3] soc: add NPCM BPC driver support In-Reply-To: <3cb1647d-c58e-4040-9e3a-61965e6a08ac@linaro.org> References: <20231212100703.3374555-1-tmaimon77@gmail.com> <3cb1647d-c58e-4040-9e3a-61965e6a08ac@linaro.org> Message-ID: Hi Krzysztof, Thanks for your comment On Wed, 13 Dec 2023 at 08:22, Krzysztof Kozlowski wrote: > > On 12/12/2023 11:07, Tomer Maimon wrote: > > This patch set adds BIOS Post code (BPC) support for the Nuvoton > > NPCM Baseboard Management Controller (BMC). > > > > Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable > > I/O addresses written by the host on the bus, the capture data > > stored in 128-word FIFO. > > > > NPCM BPC can support capture double words. > > > > The NPCM BPC driver tested on NPCM750 Olympus board. > > Where is the changelog? Sorry i forgot to add the change log, I will do it in version 3 > > Best regards, > Krzysztof > Best regards, Tomer From liuxiwei1013 at gmail.com Wed Dec 13 21:33:09 2023 From: liuxiwei1013 at gmail.com (George Liu) Date: Wed, 13 Dec 2023 18:33:09 +0800 Subject: [PATCH v1 1/1] ARM: dts: aspeed: Add IEISystems FP5280G3 BMC machine Message-ID: <20231213103309.2754291-1-liuxiwei@ieisystem.com> The IEISystems FP5280G3 is a power platform server with an AST2600-based BMC. This dts file provides a basic configuration for its OpenBMC development. Signed-off-by: George Liu --- .../aspeed/aspeed-bmc-ieisystems-fp5280g3.dts | 999 ++++++++++++++++++ 1 file changed, 999 insertions(+) create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts new file mode 100644 index 000000000000..30ee506a88e1 --- /dev/null +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts @@ -0,0 +1,999 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2023, IEISystems Corporation + +/dts-v1/; + +#include "aspeed-g6.dtsi" +#include "ibm-power10-dual.dtsi" +#include "ibm-power10-quad.dtsi" +#include +#include + +/ { + model = "FP5280G3 BMC"; + compatible = "ieisystems,fp5280g3-bmc", "aspeed,ast2600"; + + aliases { + i2c2001 = &i2c2s0ch1; + i2c2002 = &i2c2s0ch2; + i2c5000 = &i2c5s0ch0; + i2c5001 = &i2c5s0ch1; + i2c5002 = &i2c5s0ch2; + i2c5003 = &i2c5s0ch3; + i2c6000 = &i2c6s0ch0; + i2c6001 = &i2c6s0ch1; + i2c6002 = &i2c6s0ch2; + i2c6003 = &i2c6s0ch3; + i2c6004 = &i2c6s0ch4; + i2c6005 = &i2c6s0ch5; + i2c6100 = &i2c6s1ch0; + i2c6101 = &i2c6s1ch1; + i2c6200 = &i2c6s2ch0; + i2c6201 = &i2c6s2ch1; + i2c12000 = &i2c12s0ch0; + i2c12001 = &i2c12s0ch1; + i2c12002 = &i2c12s0ch2; + i2c12003 = &i2c12s0ch3; + i2c12100 = &i2c12s1ch0; + i2c12101 = &i2c12s1ch1; + i2c12102 = &i2c12s1ch2; + i2c13000 = &i2c13s0ch0; + i2c13001 = &i2c13s0ch1; + i2c13002 = &i2c13s0ch2; + i2c13003 = &i2c13s0ch3; + }; + + chosen { + stdout-path = &uart5; + bootargs = "console=ttyS4,115200n8 earlycon"; + }; + + memory at 80000000 { + device_type = "memory"; + reg = <0x80000000 0x80000000>; + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + ramoops at b3e00000 { + compatible = "ramoops"; + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ + record-size = <0x8000>; + console-size = <0x8000>; + ftrace-size = <0x8000>; + pmsg-size = <0x8000>; + max-reason = <3>; /* KMSG_DUMP_EMERG */ + }; + + /* LPC FW cycle bridge region requires natural alignment */ + flash_memory: region at b4000000 { + no-map; + reg = <0xb4000000 0x04000000>; /* 64M */ + }; + + /* VGA region is dictated by hardware strapping */ + vga_memory: region at bf000000 { + no-map; + compatible = "shared-dma-pool"; + reg = <0xbf000000 0x01000000>; /* 16M */ + }; + + video_engine_memory: jpegbuffer { + size = <0x02000000>; /* 32M */ + alignment = <0x01000000>; + compatible = "shared-dma-pool"; + reusable; + }; + gfx_memory: framebuffer { + size = <0x01000000>; + alignment = <0x01000000>; + compatible = "shared-dma-pool"; + reusable; + }; + }; + + iio-hwmon { + compatible = "iio-hwmon"; + io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, + <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, + <&adc0 7>, <&adc1 0>; + }; + + gpio-keys { + compatible = "gpio-keys"; + + cpld { + label = "cpld"; + gpios = <&gpio0 ASPEED_GPIO(S, 4) GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + bmc-heart-beat { + gpios = <&gpio0 ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + bmc-init-ok { + gpios = <&gpio0 ASPEED_GPIO(R, 5) GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + chassis-power-on { + gpios = <&gpio0 ASPEED_GPIO(Q, 3) GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + bmc-bootup { + gpios = <&gpio0 ASPEED_GPIO(S, 0) GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + fan-watchdog { + label = "fan-watchdog"; + gpios = <&gpio0 ASPEED_GPIO(E, 0) GPIO_ACTIVE_LOW>; + linux,default-trigger = "timer"; + }; + }; + +}; + +&adc0 { + status = "okay"; + aspeed,int-vref-microvolt = <2500000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc0_default + &pinctrl_adc1_default + &pinctrl_adc2_default + &pinctrl_adc3_default + &pinctrl_adc4_default + &pinctrl_adc5_default + &pinctrl_adc6_default + &pinctrl_adc7_default>; +}; + +&adc1 { + status = "okay"; + aspeed,int-vref-microvolt = <2500000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc8_default>; +}; + +&gpio0 { + gpio-line-names = + /*A0-A7*/ "","","","","","","","", + /*B0-B7*/ "","","","","","","","", + /*C0-C7*/ "","","","","","","","", + /*D0-D7*/ "","","","","","","","", + /*E0-E7*/ "","","","","","","","", + /*F0-F7*/ "","","","","","","","", + /*G0-G7*/ "","","","","","","","", + /*H0-H7*/ "","","","","","","","", + /*I0-I7*/ "","","","","","","","", + /*J0-J7*/ "","","","","","","","", + /*K0-K7*/ "","","","","","","","", + /*L0-L7*/ "","","","","","","","", + /*M0-M7*/ "","","","","","","","", + /*N0-N7*/ "","","","","SCM_CPLD_UPDATE_HITLESS","","","", + /*O0-O7*/ "","","","","","","","", + /*P0-P7*/ "","","","","","","","", + /*Q0-Q7*/ "","","","","","FM_PSU1_PRSNT_N","FM_PSU0_PRSNT_N","MB_CPLD_UPDATE_HITLESS", + /*R0-R7*/ "","","","checkstop","","","power-chassis-control","power-button", + /*S0-S7*/ "","","POSTFINISH","","","FM_BATTERY_SENSE_EN","","", + /*T0-T7*/ "","","","","","","","", + /*U0-U7*/ "","","","","","","","", + /*V0-V7*/ "","","","","power-chassis-good","","","", + /*W0-W7*/ "","","","","","","","", + /*X0-X7*/ "","","","","","","","", + /*Y0-Y7*/ "","","","","","","","", + /*Z0-Z7*/ "","","","","","","",""; +}; + +&mdio1 { + status = "okay"; + + ethphy1: ethernet-phy at 0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; +}; + +&mac2 { + status = "okay"; + + phy-mode = "rgmii"; + phy-handle = <ðphy1>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rgmii3_default>; +}; + +&mac3 { + status = "okay"; + + phy-mode = "rmii"; + use-ncsi; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rmii4_default>; +}; + +&emmc_controller { + status = "okay"; +}; + +&pinctrl_emmc_default { + bias-disable; +}; + +&emmc { + status = "okay"; + clk-phase-mmc-hs200 = <180>, <180>; +}; + +&fsim0 { + cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 4) GPIO_ACTIVE_LOW>; +} + +&i2c1 { + status = "okay"; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "Sys_Outlet_Temp"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; +}; + +&i2c2 { + status = "okay"; + tmp112 at 40{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "Inlet_Temp"; + }; + + pca9548 at 70{ + compatible = "nxp,pca9548"; + reg = <0x70>; + i2c2s0ch1: i2c at 1{ + reg = <1>; + tmp112 at 49{ + compatible = "ti,tmp112"; + reg = <0x49>; + label = "PSU_Inlet0_Temp"; + }; + tmp112 at 4a{ + compatible = "ti,tmp112"; + reg = <0x4a>; + label = "PSU_Inlet1_Temp"; + }; + }; + i2c2s0ch2: i2c at 2{ + reg = <2>; + tmp112 at 49{ + compatible = "ti,tmp112"; + reg = <0x49>; + label = "L_OCP_ZONE_Temp"; + }; + tmp112 at 4a{ + compatible = "ti,tmp112"; + reg = <0x4a>; + label = "R_OCP_ZONE_Temp"; + }; + }; + }; + + pca0:pca9555 at 20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "OCP0_CABLE_PRSNT_N", "OCP0_BIF2_N", + "OCP0_BIF1_N", "OCP0_BIF0_N", + "OCP0_CARD_PRSNTB3_ISO_N", "OCP0_CARD_PRSNTB2_ISO_N", + "OCP0_CARD_PRSNTB1_ISO_N", "OCP0_CARD_PRSNTB0_ISO_N", + "PE_MCIO0_BP_ID0_Q_N", "PE_MCIO0_BP_ID1_Q_N", + "PE_MCIO1_BP_ID0_Q_N", "PE_MCIO1_BP_ID1_Q_N", + "PE_MCIO2_BP_ID0_Q_N", "PE_MCIO2_BP_ID1_Q_N", + "RISER0_PRSNT_N", "REAR_HDD_PRSNT_N"; + }; + pca1:pca9555 at 21 { + compatible = "nxp,pca9555"; + reg = <0x21>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "OCP1_CABLE_PRSNT_N", "OCP1_BIF2_N", + "OCP1_BIF1_N", "OCP1_BIF0_N", + "OCP1_CARD_PRSNTB3_ISO_N", "OCP1_CARD_PRSNTB2_ISO_N", + "OCP1_CARD_PRSNTB1_ISO_N", "OCP1_CARD_PRSNTB0_ISO_N", + "PE_MCIO3_BP_ID0_Q_N", "PE_MCIO3_BP_ID1_Q_N", + "PE_MCIO4_BP_ID0_Q_N", "PE_MCIO4_BP_ID1_Q_N", + "PE_MCIO5_BP_ID0_Q_N", "PE_MCIO5_BP_ID1_Q_N", + "RISER2_PRSNT_N", "RISER1_PRSNT_N"; + }; + pca2:pca9555 at 22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER2_BOARD_ID1_N", "RISER2_BOARD_ID0_N", + "RISER1_BOARD_ID2_N", "RISER1_BOARD_ID1_N", + "RISER1_BOARD_ID0_N", "RISER0_BOARD_ID2_N", + "RISER0_BOARD_ID1_N", "RISER0_BOARD_ID0_N", + "PE_MCIO6_BP_ID0_Q_N", "PE_MCIO6_BP_ID1_Q_N", + "PE_MCIO7_BP_ID0_Q_N", "PE_MCIO7_BP_ID1_Q_N", + "PE_MCIO8_BP_ID0_Q_N", "PE_MCIO8_BP_ID1_Q_N", + "PE_MCIO9_BP_ID0_Q_N", "PE_MCIO9_BP_ID0_Q_N"; + }; + pca3:pca9555 at 23 { + compatible = "nxp,pca9555"; + reg = <0x23>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", + "", "", + "", "", + "", "RISER2_BOARD_ID2_N", + "PE_MCIO10_BP_ID0_Q_N", "PE_MCIO10_BP_ID1_Q_N", + "PE_MCIO7_BP_ID11_Q_N", "PE_MCIO11_BP_ID1_Q_N", + "PE_MCIO12_BP_ID0_Q_N", "PE_MCIO12_BP_ID1_Q_N", + "PE_MCIO13_BP_ID0_Q_N", "PE_MCIO13_BP_ID0_Q_N"; + }; +}; + +&i2c3 { + status = "okay"; + pca9548 at 70 { + compatible = "nxp,pca9548"; + reg = <0x70>; + }; +}; + +&i2c5 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c5s0ch0: i2c at 0 { + reg = <0>; + status = "okay"; + cpu0vdda at 60 { + compatible = "infineon,xdpe132g5c"; + reg = <0x60>; + }; + cpu0vddb at 61 { + compatible = "infineon,xdpe132g5c"; + reg = <0x61>; + }; + cpu0vdn at 72 { + compatible = "infineon,ir35221"; + reg = <0x72>; + }; + cpu0vio at 73 { + compatible = "infineon,ir35221"; + reg = <0x73>; + }; + cpu0vpci at 74 { + compatible = "infineon,ir35221"; + reg = <0x74>; + }; + }; + i2c5s0ch1: i2c at 1{ + reg = <1>; + status = "okay"; + cpu1vddc at 60 { + compatible = "infineon,xdpe132g5c"; + reg = <0x60>; + }; + cpu1vddd at 61 { + compatible = "infineon,xdpe132g5c"; + reg = <0x61>; + }; + cpu1vdn at 72 { + compatible = "infineon,ir35221"; + reg = <0x72>; + }; + cpu1vio at 73 { + compatible = "infineon,ir35221"; + reg = <0x73>; + }; + cpu1vpci at 74 { + compatible = "infineon,ir35221"; + reg = <0x74>; + }; + }; + i2c5s0ch2: i2c at 2{ + reg = <2>; + status = "okay"; + pxe1610 at 6c { + compatible = "infineon,pxe1610"; + reg = <0x6c>; + }; + rdimm at 74 { + compatible = "infineon,pxe1610"; + reg = <0x74>; + }; + mdimm at 54 { + compatible = "infineon,pxe1610"; + reg = <0x5A>; + }; + ldimm at 44 { + compatible = "infineon,pxe1610"; + reg = <0x5C>; + }; + }; + i2c5s0ch3: i2c at 3{ + reg = <3>; + }; + }; +}; + +&i2c6 { + /* SMB_TEMPSENSOR_STBY_LVC3_R */ + multi-master; + status = "okay"; + + i2c-switch at 70 { + compatible = "nxp,pca9548"; + reg = <0x70>; + #address-cells = <1>; + #size-cells = <0>; + + i2c6s0ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch2: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch3: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + + pca9548 at 71 { + compatible = "nxp,pca9548"; + reg = <0x71>; + i2c-mux-idle-disconnect; + + i2c6s1ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + i2c6s1ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; + i2c6s0ch4: i2c at 4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + + pca9548 at 71 { + compatible = "nxp,pca9548"; + reg = <0x71>; + i2c-mux-idle-disconnect; + + i2c6s2ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + i2c6s2ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; + i2c6s0ch5: i2c at 5 { + #address-cells = <1>; + #size-cells = <0>; + reg = <5>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + }; +}; + +&i2c7 { + status = "okay"; + adc128d818 at 1d{ + compatible = "ti,adc128d818"; + reg = <0x1d>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 1e{ + compatible = "ti,adc128d818"; + reg = <0x1e>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 1f{ + compatible = "ti,adc128d818"; + reg = <0x1f>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2d{ + compatible = "ti,adc128d818"; + reg = <0x2d>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2e{ + compatible = "ti,adc128d818"; + reg = <0x2e>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2f{ + compatible = "ti,adc128d818"; + reg = <0x2f>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 35{ + compatible = "ti,adc128d818"; + reg = <0x35>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 36{ + compatible = "ti,adc128d818"; + reg = <0x36>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 37{ + compatible = "ti,adc128d818"; + reg = <0x37>; + ti,mode = /bits/ 8 <0x01>; + }; +}; + +&i2c8 { + status = "okay"; + nct7362 at 20 { + compatible = "nuvoton,nct7362"; + device-active-gpios = <&gpio0 ASPEED_GPIO(N, 5) GPIO_ACTIVE_HIGH>; + reg = <0x20>; + }; + + nct7362 at 22 { + compatible = "nuvoton,nct7362"; + device-active-gpios = <&gpio0 ASPEED_GPIO(N, 5) GPIO_ACTIVE_HIGH>; + reg = <0x22>; + }; + + pca9555 at 24{ + compatible = "nxp,pca9555"; + reg = <0x24>; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "FAN_PRSNT5_D_N", "FAN_PRSNT4_D_N", + "FAN_PRSNT3_D_N", "FAN_PRSNT2_D_N", + "FAN_PRSNT1_D_N", "FAN_PRSNT0_D_N", + "", "", + "", "", "", "", + "", "", "", ""; + }; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; + +}; + +&i2c9 { + status = "okay"; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; +}; + +&i2c10 { + status = "okay"; + pca9555 at 20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "DIMM0_FAULT", "DIMM3_FAULT", + "DIMM2_FAULT", "DIMM1_FAULT", + "DIMM4_FAULT", "DIMM5_FAULT", + "DIMM6_FAULT", "DIMM7_FAULT", + "DIMM8_FAULT", "DIMM11_FAULT", + "DIMM10_FAULT", "DIMM9_FAULT", + "DIMM12_FAULT", "DIMM13_FAULT", + "DIMM14_FAULT", "DIMM15_FAULT"; + }; + + pca9555 at 22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", "", "", "OCP0_PRSNT_N", "", "", "", + "", "", "", "", "", "", "", ""; + }; + + pca9555 at 23 { + compatible = "nxp,pca9555"; + reg = <0x23>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", "", "", "OCP1_PRSNT_N", "", "", "", + "", "", "", "", "", "", "", ""; + }; +}; + +&i2c11 { + status = "okay"; + bus-timeout-ms = <100>; + bus-recover-timeout-ms = <10>; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; +}; + +&i2c12 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c-mux-idle-disconnect; + i2c12s0ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_0"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER0_BOARD_ID7", "RISER0_BOARD_ID6", + "RISER0_BOARD_ID5", "RISER0_BOARD_ID4", + "RISER0_BOARD_ID3", "RISER0_BOARD_ID2", + "RISER0_BOARD_ID1", "RISER0_BOARD_ID0", + "RISER0_SLOT2_PRSNT", "RISER0_SLOT1_PRSNT_X8", + "RISER0_SLOT0_PRSNT_X8", "RISER0_SLOT1_PRSNT_X16", + "RISER0_SLOT0_PRSNT_X16", "", "", ""; + }; + }; + i2c12s0ch1: i2c at 1{ + reg = <1>; + }; + i2c12s0ch2: i2c at 2{ + reg = <2>; + }; + i2c12s0ch3: i2c at 3{ + reg = <3>; + }; + }; + + pca9546 at 71{ + compatible = "nxp,pca9546"; + reg = <0x71>; + i2c-mux-idle-disconnect; + i2c12s1ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_2"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER2_BOARD_ID0", "RISER2_BOARD_ID1", + "RISER2_BOARD_ID2", "RISER2_BOARD_ID3", + "RISER2_BOARD_ID4", "RISER2_BOARD_ID5", + "RISER2_BOARD_ID6", "RISER2_BOARD_ID7", + "RISER2_SLOT0_PRSNT", "RISER2_SLOT1_PRSNT", + "", "", "", "", "", ""; + }; + }; + i2c12s1ch1: i2c at 1{ + reg = <1>; + }; + i2c12s1ch2: i2c at 2{ + reg = <2>; + }; + }; +}; + +&i2c13 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c-mux-idle-disconnect; + i2c13s0ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_1"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER1_BOARD_ID7", "RISER1_BOARD_ID6", + "RISER1_BOARD_ID5", "RISER1_BOARD_ID4", + "RISER1_BOARD_ID3", "RISER1_BOARD_ID2", + "RISER1_BOARD_ID1", "RISER1_BOARD_ID0", + "RISER1_SLOT2_PRSNT", "RISER1_SLOT1_PRSNT_X8", + "RISER1_SLOT0_PRSNT_X8", "RISER1_SLOT1_PRSNT_X16", + "RISER1_SLOT0_PRSNT_X16", "", "", ""; + }; + }; + i2c13s0ch1: i2c at 1{ + reg = <1>; + }; + i2c13s0ch2: i2c at 2{ + reg = <2>; + }; + i2c13s0ch3: i2c at 3{ + reg = <3>; + }; + }; +}; + +&i2c14 { + status = "okay"; + idt1339 at 68{ + compatible = "renesas,idt1339"; + reg = <0x68>; + }; +}; + +&i2c15 { + status = "okay"; +}; + +&ibt { + status = "okay"; +}; + +&uart1 { + status = "okay"; +}; + +&vuart1 { + status = "okay"; +}; + +&vuart2 { + status = "okay"; +}; + +&lpc_ctrl { + status = "okay"; + memory-region = <&flash_memory>; +}; + +&wdt1 { + status = "okay"; + aspeed,reset-mask1 = <0x20f1ff1>; +}; + +&kcs2 { + status = "okay"; + aspeed,lpc-io-reg = <0xca8 0xcac>; +}; + +&kcs3 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; +}; + +&pcieh { + status = "okay"; +}; + +&mctp { + status = "okay"; +}; + +&bmc_dev { + status = "okay"; +}; + +&vhub { + status = "okay"; +}; + +&video { + status = "okay"; + memory-region = <&video_engine_memory>; +}; + +&gfx { + status = "okay"; + memory-region = <&gfx_memory>; +}; -- 2.34.1 From fancer.lancer at gmail.com Thu Dec 14 02:27:53 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Wed, 13 Dec 2023 18:27:53 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: <20231205115234.7ntjvymurot5nnak@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205115234.7ntjvymurot5nnak@skbuf> Message-ID: Hi Vladimir, On Tue, Dec 05, 2023 at 01:52:34PM +0200, Vladimir Oltean wrote: > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > or explicitly registered in the MDIO subsystem by means of the > > mdiobus_register_board_info() method > > mdiobus_register_board_info() has exactly one caller, and that is > dsa_loop. I don't understand the relevance of it w.r.t. Synopsys XPCS. > I'm reading the patches in order from the beginning. Well, one user of the DW XPCS driver is updated in this series in the framework of the patch: [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device https://lore.kernel.org/netdev/20231205103559.9605-14-fancer.lancer at gmail.com/ I can convert of them (it's sja1105 and wangxun txgbe) and then just drop the MDIO-device creation part from xpcs_create_mdiodev(). As I also described in another emails thread below this patch I used to think that unmasking non-PHY device is also appropriate to get the MDIO-device instance. I was wrong in that matter obviously. Anyway I just realized that my solution of using mdiobus_register_board_info() is a bit clumsy. Moreover the patch 13 (see the link above) shouldn't have the mdio_board_info instance allocation (it can be defined on stack) and most importantly is wrong in using the device-managed resources for it. The problem is that mdiobus_register_board_info() registers an MDIO-device once for entire system lifetime. It isn't that suitable for the hot-swappable devices and for drivers bind/unbind cases. Since there is no mdio_board_info-deregistration method, at the simplest case the no longer used board-info descriptors might be left registered if a device or driver are unloaded. That's why the device-managed allocation is harmful in such scenario. At the very least I'll need to convert the allocations to being non-managed. > > > there is no point in creating the dummy MDIO device instance in order > > Why dummy? There's nothing dummy about the mdio_device. It's how the PCS > code accesses the hardware. I call it 'dummy' because no actual device is registered (though 'redundant' or similar definition might sound more appropriate). The entire structure is used as a communication layer between the XPCS driver and MDIO device, where the device address is the only info needed. Basically nothing prevents us from converting the current DW XPCS driver to using the mdiobus_c45_read()/mdiobus_c45_write() methods. Though in that case I wouldn't be able to easily add the fwnode-based MDIO-devices support. > > > to get the DW XPCS handler since the MDIO core subsystem will create > > the device during the MDIO bus registration procedure. > > It won't, though? Unless someone is using mdiobus_register_board_info() > possibly, but who does that? As I said above I wrongly assumed that unmasking non-PHY device was ok. But mdiobus_register_board_info() could be used for that as I (a bit clumsy) demonstrated in the patch 13. > > > All what needs to be done is to just reuse the MDIO-device instance > > available in the mii_bus.mdio_map array (using some getter for it > > would look better though). It shall prevent the XPCS devices been > > accessed over several MDIO-device instances. > > > > Note since the MDIO-device instance might be retrieved from the MDIO-bus > > map array its reference counter shall be increased. If the MDIO-device > > instance is created in the xpcs_create_mdiodev() method its reference > > counter will be already increased. So there is no point in toggling the > > reference counter in the xpcs_create() function. Just drop it from there. > > > > Signed-off-by: Serge Semin > > --- > > Sorry, because the commit log lost me at the "context presentation" stage, > I failed to understand the "what"s and the "why"s. > > Are you basically trying to add xpcs support on top of an mdio_device > where the mdio_device_create() call was made externally to the xpcs code, > through mdiobus_register_board_info() and mdiobus_setup_mdiodev_from_board_info()? Basically yes, but there is more of it. The main idea is to convert the XPCS driver to using the already created non-PHY MDIO-devices instead of manually creating a 'dummy'/'redundant' one. From my point of view there are several reasons of doing so: 1. mdiobus_register_board_info() provides a way to assign the device platform data to being registered afterwards device. Thus we can pass some custom data to the XPCS-device driver (whether it's just an xpcs_create_*() call or a fully functional MDIO-device driver registered by the mdio_driver_register() method). For instance it can be utilized to drop the fake PHYSIDs implementation from drivers/net/dsa/sja1105/sja1105_mdio.c . 2. The MDIO-devices actually registered on the MDIO-bus will be visible in sysfs with for instance useful IO statistics provided by the MDIO-bus. Potentially (if it is required) at some point we'll be able to convert the DW XPCS driver to being true MDIO-device driver (bindable to the DW XPCS device) with less efforts. 3. Having an MDIO-device registered that way would make the DW XPCS IO-device implementation unified after the fwnode-based XPCS descriptor creation support is added in one of the subsequent patches. So based on the listed above I've got a question. Do you think all of that is worth to be implemented? Andrew, Russell? I am asking because the patchset advance depends on your answers. If you do I'll need to fix the problem described in my first message, implement some new mdiobus_register_board_info()-like but MDIO-bus-specific interface function (so MDIO-device infos would be attached to the allocated MDIO-bus and then used to register the respective MDIO-devices on the MDIO-bus registration), then convert the sja1105 and wangxun txgbe drivers to using it. If you don't I'll get back the xpcs_create_mdiodev() implementation and just provide a fwnode-based version of one. Note we already settled that converting DW XPCS driver to being normal MDIO-device driver is prone to errors at this stage due to a possibility to have the driver unbindable from user-space. I'll just move the DT-compatibles check to the xpcs_create_fwnode() method and drop the rest of the MDIO-device-driver-specific things. -Serge(y) From andy at kernel.org Thu Dec 14 02:27:02 2023 From: andy at kernel.org (Andy Shevchenko) Date: Wed, 13 Dec 2023 17:27:02 +0200 Subject: [PATCH v9 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: <20231212065147.3475413-4-jim.t90615@gmail.com> References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-4-jim.t90615@gmail.com> Message-ID: On Tue, Dec 12, 2023 at 02:51:47PM +0800, Jim Liu wrote: > Add Nuvoton BMC NPCM7xx/NPCM8xx sgpio driver support. > Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) > and parallel to serial IC (HC165), and use APB3 clock to control it. > This interface has 4 pins (D_out , D_in, S_CLK, LDSH). > BMC can use this driver to increase 64 GPI pins and 64 GPO pins to use. ... > +#include > +#include > +#include > +#include > +#include > +#include > +#include Is this a proxy to some other headers like array_size.h? Please use respective headers directly. > +#include > +#include > +#include > +#include ... > +#define NPCM_CLK_MHZ 8000000 HZ_PER_MHZ from units.h? ... > +struct npcm_sgpio { > + struct gpio_chip chip; > + struct clk *pclk; > + struct irq_chip intc; > + raw_spinlock_t lock; /*protect event config*/ Missing spaces. > + void __iomem *base; > + int irq; > + u8 nin_sgpio; > + u8 nout_sgpio; > + u8 in_port; > + u8 out_port; > + u8 int_type[MAX_NR_HW_SGPIO]; > +}; ... > + { > + .wdata_reg = 0x07, > + .rdata_reg = 0x0f, > + .event_config = 0x1e, > + .event_status = 0x27, > + }, > + Redundant blank line. ... > +static void __iomem *bank_reg(struct npcm_sgpio *gpio, > + const struct npcm_sgpio_bank *bank, > + const enum npcm_sgpio_reg reg) > +{ > + switch (reg) { > + case READ_DATA: > + return gpio->base + bank->rdata_reg; > + case WRITE_DATA: > + return gpio->base + bank->wdata_reg; > + case EVENT_CFG: > + return gpio->base + bank->event_config; > + case EVENT_STS: > + return gpio->base + bank->event_status; > + default: > + /* actually if code runs to here, it's an error case */ > + dev_WARN(gpio->chip.parent, "Getting here is an error condition"); ...then return an error here. > + } > + return 0; See above. > +} > +static void irqd_to_npcm_sgpio_data(struct irq_data *d, Respect namespace, here it's better to have npcm_sgpio_irqd_to_data(). > + struct npcm_sgpio **gpio, > + const struct npcm_sgpio_bank **bank, > + u8 *bit, unsigned int *offset) ... > +static int npcm_sgpio_init_port(struct npcm_sgpio *gpio) > +{ > + u8 in_port, out_port, set_port, reg; > + > + in_port = GPIO_BANK(gpio->nin_sgpio); > + if (GPIO_BIT(gpio->nin_sgpio) > 0) > + in_port += 1; This is strange... So, you are telling that offsets start from 1 and not 0? > + out_port = GPIO_BANK(gpio->nout_sgpio); > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > + out_port += 1; Ditto. ... > + set_port = ((out_port & NPCM_IOXCFG2_PORT) << 4) | (in_port & NPCM_IOXCFG2_PORT); Outer parentheses are redundant. ... > +static int npcm_sgpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val) > +{ > + gc->set(gc, offset, val); > + > + return 0; > + Redundant blank line. > +} > + > +static int npcm_sgpio_get_direction(struct gpio_chip *gc, unsigned int offset) > +{ > + struct npcm_sgpio *gpio = gpiochip_get_data(gc); > + if (offset > gpio->chip.ngpio) > + return -EINVAL; Why do you need this check? > + if (offset < gpio->nout_sgpio) > + return GPIO_LINE_DIRECTION_OUT; > + > + return GPIO_LINE_DIRECTION_IN; > +} ... > +static void npcm_sgpio_set(struct gpio_chip *gc, unsigned int offset, int val) > +{ > + struct npcm_sgpio *gpio = gpiochip_get_data(gc); > + const struct npcm_sgpio_bank *bank = offset_to_bank(offset); > + void __iomem *addr; > + u8 reg = 0; > + > + addr = bank_reg(gpio, bank, WRITE_DATA); > + reg = ioread8(addr); > + > + if (val) > + reg |= (val << GPIO_BIT(offset)); ...and if val is not 1?.. > + else > + reg &= ~(1 << GPIO_BIT(offset)); In both cases use BIT(). > + iowrite8(reg, addr); > +} ... > + dir = npcm_sgpio_get_direction(gc, offset); > + if (dir == 0) { > + bank = offset_to_bank(offset); > + > + addr = bank_reg(gpio, bank, WRITE_DATA); > + reg = ioread8(addr); > + reg = !!(reg & GPIO_BIT(offset)); > + } else { > + offset -= gpio->nout_sgpio; > + bank = offset_to_bank(offset); > + > + addr = bank_reg(gpio, bank, READ_DATA); > + reg = ioread8(addr); > + reg = !!(reg & GPIO_BIT(offset)); > + } Instead of conditional(s) use arithmetics. You can get all these directly from the properly formed calculations. ... > +static void npcm_sgpio_setup_enable(struct npcm_sgpio *gpio, bool enable) > +{ > + u8 reg = 0; Redundant assignment. > + reg = ioread8(gpio->base + NPCM_IOXCTS); > + reg = reg & ~NPCM_IOXCTS_RD_MODE; > + reg = reg | NPCM_IOXCTS_RD_MODE_PERIODIC; Combine them. > + if (enable) { > + reg |= NPCM_IOXCTS_IOXIF_EN; > + iowrite8(reg, gpio->base + NPCM_IOXCTS); > + } else { > + reg &= ~NPCM_IOXCTS_IOXIF_EN; > + iowrite8(reg, gpio->base + NPCM_IOXCTS); > + } > +} ... > +static int npcm_sgpio_setup_clk(struct npcm_sgpio *gpio, > + const struct npcm_clk_cfg *clk_cfg) > +{ > + unsigned long apb_freq; > + u32 val; > + u8 tmp; > + int i; > + > + apb_freq = clk_get_rate(gpio->pclk); > + tmp = ioread8(gpio->base + NPCM_IOXCFG1) & ~NPCM_IOXCFG1_SFT_CLK; > + > + for (i = 0; i < clk_cfg->cfg_opt; i++) { > + val = apb_freq / clk_cfg->sft_clk[i]; > + if ((NPCM_CLK_MHZ < val) && (i != 0) ) { > + iowrite8(clk_cfg->clk_sel[i-1] | tmp, gpio->base + NPCM_IOXCFG1); > + return 0; > + } else if (i == (clk_cfg->cfg_opt-1) && (NPCM_CLK_MHZ > val)) { > + iowrite8(clk_cfg->clk_sel[i] | tmp, gpio->base + NPCM_IOXCFG1); > + return 0; > + } These i == / i != checks probably due to wrong operator be chosen. Consider using while-loop, or do-while. I believe it will make code better. > + } > + > + return -EINVAL; > +} ... > +static void npcm_sgpio_irq_init_valid_mask(struct gpio_chip *gc, > + unsigned long *valid_mask, unsigned int ngpios) > +{ > + struct npcm_sgpio *gpio = gpiochip_get_data(gc); > + int n = gpio->nin_sgpio; Why do you need this variable, what for? > + /* input GPIOs in the high range */ > + bitmap_set(valid_mask, gpio->nout_sgpio, n); > + bitmap_clear(valid_mask, 0, gpio->nout_sgpio); > +} ... > + raw_spin_lock_irqsave(&gpio->lock, flags); Don't you need to use spin lock in the other APIs? It seem whole driver works by luck. > + npcm_sgpio_setup_enable(gpio, false); > + > + reg = ioread16(addr); > + if (set) { > + reg &= ~(NPCM_IXOEVCFG_MASK << (bit * 2)); > + } else { > + type = gpio->int_type[offset]; > + reg |= (type << (bit * 2)); At least the calculations can be done outside of the lock. > + } > + > + iowrite16(reg, addr); > + > + npcm_sgpio_setup_enable(gpio, true); > + > + addr = bank_reg(gpio, bank, EVENT_STS); > + reg = ioread8(addr); > + reg |= BIT(bit); > + iowrite8(reg, addr); > + > + raw_spin_unlock_irqrestore(&gpio->lock, flags); ... > + switch (type & IRQ_TYPE_SENSE_MASK) { > + case IRQ_TYPE_EDGE_BOTH: > + val = NPCM_IXOEVCFG_BOTH; > + handler = handle_edge_irq; > + break; > + case IRQ_TYPE_EDGE_RISING: > + val = NPCM_IXOEVCFG_RISING; > + handler = handle_edge_irq; > + break; > + case IRQ_TYPE_EDGE_FALLING: > + val = NPCM_IXOEVCFG_FALLING; > + handler = handle_edge_irq; > + break; > + case IRQ_TYPE_LEVEL_HIGH: > + val = NPCM_IXOEVCFG_RISING; > + handler = handle_level_irq; > + break; > + case IRQ_TYPE_LEVEL_LOW: > + val = NPCM_IXOEVCFG_FALLING; > + handler = handle_level_irq; > + break; > + default: > + return -EINVAL; > + } You can split the handler setup and make this function less by 5 LoCs or so. See, for example, gpio-tangier.c. ... > + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { > + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; > + > + reg = ioread8(bank_reg(gpio, bank, EVENT_STS)); > + for_each_set_bit(j, ®, 8) { > + girq = irq_find_mapping(gc->irq.domain, i * 8 + gpio->nout_sgpio + j); > + generic_handle_irq(girq); generic_handle_domain_irq() > + } > + } ... > +static int npcm_sgpio_setup_irqs(struct npcm_sgpio *gpio, > + struct platform_device *pdev) > +{ > + int rc, i; > + struct gpio_irq_chip *irq; > + > + rc = platform_get_irq(pdev, 0); > + if (rc < 0) > + return rc; > + > + gpio->irq = rc; > + > + npcm_sgpio_setup_enable(gpio, false); > + > + /* Disable IRQ and clear Interrupt status registers for all SGPIO Pins. */ > + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { > + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; > + iowrite16(0x0000, bank_reg(gpio, bank, EVENT_CFG)); 0 is enough. > + iowrite8(0xff, bank_reg(gpio, bank, EVENT_STS)); GENMASK() ? > + } > + > + irq = &gpio->chip.irq; > + gpio_irq_chip_set_chip(irq, &sgpio_irq_chip); > + irq->init_valid_mask = npcm_sgpio_irq_init_valid_mask; > + irq->handler = handle_bad_irq; > + irq->default_type = IRQ_TYPE_NONE; > + irq->parent_handler = npcm_sgpio_irq_handler; > + irq->parent_handler_data = gpio; > + irq->parents = &gpio->irq; > + irq->num_parents = 1; > + > + return 0; > +} ... > +static struct npcm_clk_cfg npcm750_sgpio_pdata = { > + .sft_clk = npcm750_SFT_CLK, > + .clk_sel = npcm750_CLK_SEL, > + .cfg_opt = 6, Define this magic and use it in the above arrays as the capacity. > +}; > + > +static const struct npcm_clk_cfg npcm845_sgpio_pdata = { > + .sft_clk = npcm845_SFT_CLK, > + .clk_sel = npcm845_CLK_SEL, > + .cfg_opt = 5, Ditto. > +}; ... > +static const struct of_device_id npcm_sgpio_of_table[] = { > + { .compatible = "nuvoton,npcm750-sgpio", .data = &npcm750_sgpio_pdata, }, > + { .compatible = "nuvoton,npcm845-sgpio", .data = &npcm845_sgpio_pdata, }, > + {} > +}; > +MODULE_DEVICE_TABLE(of, npcm_sgpio_of_table); Move this closer to its user below. ... > + if (gpio->nin_sgpio > MAX_NR_HW_SGPIO || gpio->nout_sgpio > MAX_NR_HW_SGPIO) { > + dev_err(&pdev->dev, "Number of GPIOs exceeds the maximum of %d: input: %d output: %d\n", > + MAX_NR_HW_SGPIO, nin_gpios, nout_gpios); > + return -EINVAL; return dev_err_probe(...); > + } > + > + gpio->pclk = devm_clk_get(&pdev->dev, NULL); > + if (IS_ERR(gpio->pclk)) { > + dev_err(&pdev->dev, "Could not get pclk\n"); > + return PTR_ERR(gpio->pclk); Ditto. > + } ... > + rc = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); > + if (rc < 0) Here and in the other cases, why ' < 0'? Does it have positive value to be returned in some cases? > + return rc; -- With Best Regards, Andy Shevchenko From fancer.lancer at gmail.com Thu Dec 14 02:47:19 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Wed, 13 Dec 2023 18:47:19 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Tue, Dec 12, 2023 at 07:06:46PM +0000, Russell King (Oracle) wrote: > On Tue, Dec 12, 2023 at 06:26:16PM +0300, Serge Semin wrote: > > I would have used in the first place if it was externally visible, but > > it's defined as static. Do you suggest to make it global or ... > > That would be one option - I didn't make it visible when I introduced it > beacuse there were no users for it. > > > > At some point, we should implement > > > mdiobus_get_mdiodev() which also deals with the refcount. > > > > ... create mdiobus_get_mdiodev() instead? > > > > * Note in the commit message I mentioned that having a getter would be > > * better than directly touching the mii_bus instance guts. > > What I'm thinking is: > > /** > * mdiobus_get_mdiodev() - get a mdiodev for the specified bus > * @bus: mii_bus to get mdio device from > * @addr: mdio address of mdio device > * > * Return the struct mdio_device attached to the MII bus @bus at MDIO > * address @addr. On success, the refcount on the device will be > * increased, which must be dropped using mdio_device_put(), and the > * mdio device returned. Otherwise, returns NULL. > */ > struct mdio_device *mdiobus_get_mdiodev(struct mii_bus *bus, int addr) > { > struct mdio_device *mdiodev; > > mdiodev = mdiobus_find_device(bus, addr); > if (mdiodev) > get_device(&mdiodev->dev); > return mdiodev; > } > EXPORT_SYMBOL(mdiobus_get_mdiodev); > > should do it, and will hold a reference on the mdiodev structure (which > won't be freed) and also on the mii_bus (since this device is a child > of the bus device, the parent can't be released until the child has > been, so struct mii_bus should at least stay around.) Right. That's exactly what had in mind. Thanks for suggesting a ready-to-apply solution. I'll add it to the series as a separate patch if we decide to keep the proposed in this patch change. See my question in the next message: https://lore.kernel.org/netdev/wnptneaxxe2tq2rf7ac6a72xtyluyggughvmtxbbg5qto64mpa at 7gchl5e4qllu/ > > What would help the "the bus driver has been unbound" situation is if > we took the mdio_lock on the bus, and then set the {read,write}{,_c45} > functions to dummy stubs when the bus is being unregistered which then > return e.g. -ENXIO. That will probably make unbinding/unloading all > MDIO bus drivers safe from kernel oops, although phylib will spit out > a non-useful backtrace if it tries an access. I don't think there's > much which can be done about that - I did propose a patch to change > that behaviour but apparently folk like having it! > > It isn't perfect - it's racy, but then accessing mdio_map[] is > inherently racy due to no locking with mdiobus_.*register_device(). > At least if we have everyone using a proper getter function rather > than directly fiddling with bus->mdio_map[]. We only have one driver > that accesses it directly at the moment (mscc_ptp): > > dev = phydev->mdio.bus->mdio_map[vsc8531->ts_base_addr]; > phydev = container_of(dev, struct phy_device, mdio); > > return phydev->priv; > > and that should really be using mdiobus_get_phy(). Regarding the driver bind/unbind. I guess the maintainers just forget about that problem. Do you think it's worth reminding them about it? -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From linux at armlinux.org.uk Thu Dec 14 03:32:21 2023 From: linux at armlinux.org.uk (Russell King (Oracle)) Date: Wed, 13 Dec 2023 16:32:21 +0000 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Wed, Dec 13, 2023 at 03:01:45AM +0300, Serge Semin wrote: > On Tue, Dec 05, 2023 at 01:46:44PM +0000, Russell King (Oracle) wrote: > > xpcs_create_mdiodev() as it originally stood creates the mdiodev from > > the bus/address, and then passes that to xpcs_create(). Once > > xpcs_create() has finished its work (irrespective of whether it was > > successful or not) we're done with the mdiodev in this function, so > > the reference is _always_ put. > > You say that it's required to manage the refcounting twice: when we > get the reference from some external place and internally when the > reference is stored in the XPCS descriptor. What's the point in such > redundancy with the internal ref-counting if we know that the pointer > can be safely stored and utilized afterwards? Better maintainability? > Is it due to having the object retrieval and storing implemented in > different functions? The point is that the error handling gets simpler: - One can see in xpcs_create_mdiodev() that the reference taken by mdio_device_create() is always dropped if that function was successful, irrespective of whether xpcs_create() was successful. - xpcs_create() is responsible for managing the refcount on the mdiodev that is passed to it - and if it's successful, it needs to increment the refcount, or leave it in the same state as it was on entry if failing. This avoids complexities in error paths, which are notorious for things being forgotten - since with this, each of these functions is resposible for managing its refcount. It's a different style of refcount management, one I think more people should adopt. > While at it if you happen to know an answer could you please also > clarify the next question. None of the ordinary > platform/PCI/USB/hwmon/etc drivers I've been working with managed > refcounting on storing a passed to probe() device pointer in the > private driver data. Is it wrong not doing that? If we wanted to do refcounting strictly, then every time a new pointer to a data structure is created, we should be taking a refcount on it, and each time that pointer is destroyed, we should be putting the refcount. That is what refcounting is all about. However, there are circumstances where this can be done lazily, and for drivers we would prefer driver authors not to end up with refcount errors where they've forgotten to put something. In the specific case of drivers, we have a well defined lifetime for a device bound to a driver. We guarantee that the struct device will not go away if a driver is bound to the device, until such time that the driver's .remove method has been called. Thus, we guarantee that the device driver will be notified of the struct device going away before it has been freed. This frees the driver author from having to worry about the refcount of the struct device. As soon as we start doing stuff that is outside of that model, then objects that are refcounted need to be dealt with, and I much prefer the "strict" refcounting implementation such as the one I added to xpcs, because IMHO it's much easier to see that the flow is obviously correct - even if it does need a comment to describe why we always do a put. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From tmaimon77 at gmail.com Thu Dec 14 06:05:27 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 21:05:27 +0200 Subject: [PATCH v3 2/3] soc: nuvoton: add configuration menu In-Reply-To: <20231213190528.3751583-1-tmaimon77@gmail.com> References: <20231213190528.3751583-1-tmaimon77@gmail.com> Message-ID: <20231213190528.3751583-3-tmaimon77@gmail.com> Add menu configuration to Nuvoton SoC drivers. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index df46182088ec..d5102f5f0c28 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -menuconfig WPCM450_SOC + +menu "NUVOTON SoC drivers" + +config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 select SOC_BUS @@ -9,3 +12,5 @@ menuconfig WPCM450_SOC This driver provides information such as the SoC model and revision. + +endmenu -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 06:05:26 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 21:05:26 +0200 Subject: [PATCH v3 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC In-Reply-To: <20231213190528.3751583-1-tmaimon77@gmail.com> References: <20231213190528.3751583-1-tmaimon77@gmail.com> Message-ID: <20231213190528.3751583-2-tmaimon77@gmail.com> Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC). The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus. Signed-off-by: Tomer Maimon --- .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml diff --git a/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file mode 100644 index 000000000000..c04302a1d52b --- /dev/null +++ b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton BMC NPCM BIOS Post Code (BPC) controller + +maintainers: + - Tomer Maimon + +description: + Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O + addresses written by the host on the bus, the capture data stored in + 128-word FIFO. + + NPCM BPC supports capture double words, when using capture + double word only I/O address 1 is monitored. + +properties: + compatible: + items: + - enum: + - nuvoton,npcm845-bpc + - nuvoton,npcm750-bpc + - const: nuvoton,npcm-bpc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + nuvoton,monitor-ports: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Contain monitor I/O addresses on the bus, at least one monitor I/O + address required. + + nuvoton,bpc-en-dwcapture: + description: + Set DWCAPTURE bit in BPCFEN register that enable double words capture + according to the first address setting. + type: boolean + +required: + - compatible + - reg + - interrupts + - nuvoton,monitor-ports + +additionalProperties: false + +examples: + - | + #include + #include + + bpc: bpc at f0007040 { + compatible = "nuvoton,npcm750-bpc", "nuvoton,npcm-bpc"; + reg = <0xf0007040 0x20>; + interrupts = ; + nuvoton,monitor-ports = <0x80>; + }; +... -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 06:05:25 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 21:05:25 +0200 Subject: [PATCH v3 0/3] soc: add NPCM BPC driver support Message-ID: <20231213190528.3751583-1-tmaimon77@gmail.com> This patch set adds BIOS Post code (BPC) support for the Nuvoton NPCM Baseboard Management Controller (BMC). Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O addresses written by the host on the bus, the capture data stored in 128-word FIFO. NPCM BPC can support capture double words. The NPCM BPC driver tested on NPCM750 Olympus board. Addressed comments from: - Krzysztof Kozlowski : https://www.spinics.net/lists/kernel/msg5035188.html - Conor Dooley : https://www.spinics.net/lists/kernel/msg5034239.html - kernel test robot : https://www.spinics.net/lists/kernel/msg5034970.html Changes since version 2: - Modify compatible bindings. - Add more details to nuvoton,bpc-en-dwcapture parameter. - Using _is_visible() function to support NPCM8XX. - add __poll_t custom. Changes since version 1: - Remove LPC present from the BPC driver. - Modify dt-bindings message header. - Add vendor to the file name. - Modify incorrect spelling. Tomer Maimon (3): dt-bindings: soc: nuvoton: Add NPCM BPC soc: nuvoton: add configuration menu soc: nuvoton: add NPCM BPC driver .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 65 +++ drivers/soc/nuvoton/Kconfig | 16 +- drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 387 ++++++++++++++++++ 4 files changed, 468 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml create mode 100644 drivers/soc/nuvoton/npcm-bpc.c -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 06:05:28 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 21:05:28 +0200 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <20231213190528.3751583-1-tmaimon77@gmail.com> References: <20231213190528.3751583-1-tmaimon77@gmail.com> Message-ID: <20231213190528.3751583-4-tmaimon77@gmail.com> Add Nuvoton BMC NPCM BIOS post code (BPC) driver. The NPCM BPC monitoring two configurable I/O address written by the host on the bus. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 9 + drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 drivers/soc/nuvoton/npcm-bpc.c diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index d5102f5f0c28..ebd162633942 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -2,6 +2,15 @@ menu "NUVOTON SoC drivers" +config NPCM_BPC + tristate "NPCM BIOS Post Code support" + depends on (ARCH_NPCM || COMPILE_TEST) + help + Provides NPCM driver to control the BIOS Post Code + interface which allows the BMC to monitor and save + the data written by the host to an arbitrary I/O port, + the BPC is connected to the host thourgh LPC or eSPI bus. + config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 diff --git a/drivers/soc/nuvoton/Makefile b/drivers/soc/nuvoton/Makefile index e30317b4e829..c6c96079c6e9 100644 --- a/drivers/soc/nuvoton/Makefile +++ b/drivers/soc/nuvoton/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_NPCM_BPC) += npcm-bpc.o obj-$(CONFIG_WPCM450_SOC) += wpcm450-soc.o diff --git a/drivers/soc/nuvoton/npcm-bpc.c b/drivers/soc/nuvoton/npcm-bpc.c new file mode 100644 index 000000000000..cb5e5a11d6d8 --- /dev/null +++ b/drivers/soc/nuvoton/npcm-bpc.c @@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2020 Nuvoton Technology corporation. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEVICE_NAME "npcm-bpc" + +#define NUM_BPC_CHANNELS 2 +#define DW_PAD_SIZE 3 + +/* BIOS POST Code FIFO Registers */ +#define NPCM_BPCFA2L_REG 0x2 //BIOS POST Code FIFO Address 2 LSB +#define NPCM_BPCFA2M_REG 0x4 //BIOS POST Code FIFO Address 2 MSB +#define NPCM_BPCFEN_REG 0x6 //BIOS POST Code FIFO Enable +#define NPCM_BPCFSTAT_REG 0x8 //BIOS POST Code FIFO Status +#define NPCM_BPCFDATA_REG 0xA //BIOS POST Code FIFO Data +#define NPCM_BPCFMSTAT_REG 0xC //BIOS POST Code FIFO Miscellaneous Status +#define NPCM_BPCFA1L_REG 0x10 //BIOS POST Code FIFO Address 1 LSB +#define NPCM_BPCFA1M_REG 0x12 //BIOS POST Code FIFO Address 1 MSB + +/* BIOS register data */ +#define FIFO_IOADDR1_ENABLE 0x80 +#define FIFO_IOADDR2_ENABLE 0x40 + +/* BPC interface package and structure definition */ +#define BPC_KFIFO_SIZE 0x400 + +/* BPC register data */ +#define FIFO_DATA_VALID 0x80 +#define FIFO_OVERFLOW 0x20 +#define FIFO_READY_INT_ENABLE 0x8 +#define FIFO_DWCAPTURE 0x4 +#define FIFO_ADDR_DECODE 0x1 + +/* Host Reset */ +#define HOST_RESET_INT_ENABLE 0x10 +#define HOST_RESET_CHANGED 0x40 + +struct npcm_bpc_channel { + struct npcm_bpc *data; + struct kfifo fifo; + wait_queue_head_t wq; + bool host_reset; + struct miscdevice miscdev; +}; + +struct npcm_bpc { + void __iomem *base; + struct device *dev; + int irq; + bool en_dwcap; + struct npcm_bpc_channel ch[NUM_BPC_CHANNELS]; +}; + +static struct npcm_bpc_channel *npcm_file_to_ch(struct file *file) +{ + return container_of(file->private_data, struct npcm_bpc_channel, + miscdev); +} + +static ssize_t npcm_bpc_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + struct npcm_bpc *bpc = chan->data; + unsigned int copied; + int cond_size = 1; + int ret = 0; + + if (bpc->en_dwcap) + cond_size = 3; + + if (kfifo_len(&chan->fifo) < cond_size) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible + (chan->wq, kfifo_len(&chan->fifo) > cond_size); + if (ret == -ERESTARTSYS) + return -EINTR; + } + + ret = kfifo_to_user(&chan->fifo, buffer, count, &copied); + + return ret ? ret : copied; +} + +static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + __poll_t mask = 0; + + poll_wait(file, &chan->wq, pt); + if (!kfifo_is_empty(&chan->fifo)) + mask = (__poll_t)POLLIN; + + if (chan->host_reset) { + mask |= (__poll_t)POLLHUP; + chan->host_reset = false; + } + + return mask; +} + +static const struct file_operations npcm_bpc_fops = { + .owner = THIS_MODULE, + .read = npcm_bpc_read, + .poll = npcm_bpc_poll, + .llseek = noop_llseek, +}; + +static irqreturn_t npcm_bpc_irq(int irq, void *arg) +{ + struct npcm_bpc *bpc = arg; + u8 fifo_st, host_st, data; + bool isr_flag = false; + u8 last_addr_bit = 0; + u8 padzero[3] = {0}; + u8 addr_index = 0; + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + while (FIFO_DATA_VALID & fifo_st) { + /* If dwcapture enabled only channel 0 (FIFO 0) used */ + if (!bpc->en_dwcap) + addr_index = fifo_st & FIFO_ADDR_DECODE; + else + last_addr_bit = fifo_st & FIFO_ADDR_DECODE; + + /* Read data from FIFO to clear interrupt */ + data = ioread8(bpc->base + NPCM_BPCFDATA_REG); + if (kfifo_is_full(&bpc->ch[addr_index].fifo)) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_put(&bpc->ch[addr_index].fifo, data); + if (fifo_st & FIFO_OVERFLOW) + dev_warn(bpc->dev, "BIOS Post Codes FIFO Overflow\n"); + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + if (bpc->en_dwcap && last_addr_bit) { + if ((fifo_st & FIFO_ADDR_DECODE) || + ((FIFO_DATA_VALID & fifo_st) == 0)) { + while (kfifo_avail(&bpc->ch[addr_index].fifo) < DW_PAD_SIZE) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_in(&bpc->ch[addr_index].fifo, + padzero, DW_PAD_SIZE); + } + } + isr_flag = true; + } + + host_st = ioread8(bpc->base + NPCM_BPCFMSTAT_REG); + if (host_st & HOST_RESET_CHANGED) { + iowrite8(HOST_RESET_CHANGED, + bpc->base + NPCM_BPCFMSTAT_REG); + bpc->ch[addr_index].host_reset = true; + isr_flag = true; + } + + if (isr_flag) { + wake_up_interruptible(&bpc->ch[addr_index].wq); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int npcm_bpc_config_irq(struct npcm_bpc *bpc, + struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int rc; + + bpc->irq = platform_get_irq(pdev, 0); + if (bpc->irq < 0) { + dev_err(dev, "get IRQ failed\n"); + return bpc->irq; + } + + rc = devm_request_irq(dev, bpc->irq, + npcm_bpc_irq, IRQF_SHARED, + DEVICE_NAME, bpc); + if (rc < 0) { + dev_warn(dev, "Unable to request IRQ %d\n", bpc->irq); + return rc; + } + + return 0; +} + +static int npcm_enable_bpc(struct npcm_bpc *bpc, struct device *dev, + int channel, u16 host_port) +{ + u8 addr_en, reg_en; + int err; + + init_waitqueue_head(&bpc->ch[channel].wq); + + err = kfifo_alloc(&bpc->ch[channel].fifo, BPC_KFIFO_SIZE, + GFP_KERNEL); + if (err) + return err; + + bpc->ch[channel].miscdev.minor = MISC_DYNAMIC_MINOR; + bpc->ch[channel].miscdev.name = + devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME, channel); + bpc->ch[channel].miscdev.fops = &npcm_bpc_fops; + bpc->ch[channel].miscdev.parent = dev; + err = misc_register(&bpc->ch[channel].miscdev); + if (err) + return err; + + bpc->ch[channel].data = bpc; + bpc->ch[channel].host_reset = false; + + /* Enable host snoop channel at requested port */ + switch (channel) { + case 0: + addr_en = FIFO_IOADDR1_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA1L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA1M_REG); + break; + case 1: + addr_en = FIFO_IOADDR2_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA2L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA2M_REG); + break; + default: + return -EINVAL; + } + + if (bpc->en_dwcap) + addr_en = FIFO_DWCAPTURE; + + /* + * Enable FIFO Ready Interrupt, FIFO Capture of I/O addr, + * and Host Reset + */ + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en | addr_en | FIFO_READY_INT_ENABLE | + HOST_RESET_INT_ENABLE, bpc->base + NPCM_BPCFEN_REG); + + return 0; +} + +static void npcm_disable_bpc(struct npcm_bpc *bpc, int channel) +{ + u8 reg_en; + + switch (channel) { + case 0: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + if (bpc->en_dwcap) + iowrite8(reg_en & ~FIFO_DWCAPTURE, + bpc->base + NPCM_BPCFEN_REG); + else + iowrite8(reg_en & ~FIFO_IOADDR1_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + case 1: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en & ~FIFO_IOADDR2_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + default: + return; + } + + if (!(reg_en & (FIFO_IOADDR1_ENABLE | FIFO_IOADDR2_ENABLE))) + iowrite8(reg_en & + ~(FIFO_READY_INT_ENABLE | HOST_RESET_INT_ENABLE), + bpc->base + NPCM_BPCFEN_REG); + + kfifo_free(&bpc->ch[channel].fifo); + misc_deregister(&bpc->ch[channel].miscdev); +} + +static int npcm_bpc_probe(struct platform_device *pdev) +{ + struct npcm_bpc *bpc; + struct device *dev; + u32 port; + int err; + + dev = &pdev->dev; + + bpc = devm_kzalloc(dev, sizeof(*bpc), GFP_KERNEL); + if (!bpc) + return -ENOMEM; + + bpc->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bpc->base)) + return PTR_ERR(bpc->base); + + dev_set_drvdata(&pdev->dev, bpc); + + err = of_property_read_u32_index(dev->of_node, "nuvoton,monitor-ports", + 0, &port); + if (err) { + dev_err(dev, "no monitor ports configured\n"); + return -ENODEV; + } + + bpc->en_dwcap = + of_property_read_bool(dev->of_node, "nuvoton,bpc-en-dwcapture"); + + bpc->dev = dev; + + err = npcm_bpc_config_irq(bpc, pdev); + if (err) + return err; + + err = npcm_enable_bpc(bpc, dev, 0, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 0 failed\n"); + return err; + } + + /* + * Configuration of second BPC channel port is optional + * Double-Word Capture ignoring address 2 + */ + if (!bpc->en_dwcap) { + if (of_property_read_u32_index(dev->of_node, + "nuvoton,monitor-ports", 1, + &port) == 0) { + err = npcm_enable_bpc(bpc, dev, 1, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 1 failed, disable I/O port 0\n"); + npcm_disable_bpc(bpc, 0); + return err; + } + } + } + + pr_info("NPCM BIOS Post Code probe\n"); + + return err; +} + +static int npcm_bpc_remove(struct platform_device *pdev) +{ + struct npcm_bpc *bpc = dev_get_drvdata(&pdev->dev); + u8 reg_en; + + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + + if (reg_en & FIFO_IOADDR1_ENABLE) + npcm_disable_bpc(bpc, 0); + if (reg_en & FIFO_IOADDR2_ENABLE) + npcm_disable_bpc(bpc, 1); + + return 0; +} + +static const struct of_device_id npcm_bpc_match[] = { + { .compatible = "nuvoton,npcm-bpc" }, + { }, +}; + +static struct platform_driver npcm_bpc_driver = { + .driver = { + .name = DEVICE_NAME, + .of_match_table = npcm_bpc_match, + }, + .probe = npcm_bpc_probe, + .remove = npcm_bpc_remove, +}; + +module_platform_driver(npcm_bpc_driver); + +MODULE_DEVICE_TABLE(of, npcm_bpc_match); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_DESCRIPTION("NPCM BIOS post code monitoring device driver"); -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 05:28:44 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 20:28:44 +0200 Subject: [PATCH v3 2/3] soc: nuvoton: add configuration menu In-Reply-To: <20231213182845.3744685-1-tmaimon77@gmail.com> References: <20231213182845.3744685-1-tmaimon77@gmail.com> Message-ID: <20231213182845.3744685-3-tmaimon77@gmail.com> Add menu configuration to Nuvoton SoC drivers. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index df46182088ec..d5102f5f0c28 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 -menuconfig WPCM450_SOC + +menu "NUVOTON SoC drivers" + +config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 select SOC_BUS @@ -9,3 +12,5 @@ menuconfig WPCM450_SOC This driver provides information such as the SoC model and revision. + +endmenu -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 05:28:42 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 20:28:42 +0200 Subject: [PATCH v3 0/3] soc: add NPCM BPC driver support Message-ID: <20231213182845.3744685-1-tmaimon77@gmail.com> This patch set adds BIOS Post code (BPC) support for the Nuvoton NPCM Baseboard Management Controller (BMC). Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O addresses written by the host on the bus, the capture data stored in 128-word FIFO. NPCM BPC can support capture double words. The NPCM BPC driver tested on NPCM750 Olympus board. Addressed comments from: - Krzysztof Kozlowski : https://www.spinics.net/lists/kernel/msg5035188.html - Conor Dooley : https://www.spinics.net/lists/kernel/msg5034239.html - kernel test robot : https://www.spinics.net/lists/kernel/msg5034970.html Changes since version 2: - Modify compatible bindings. - Add more details to nuvoton,bpc-en-dwcapture parameter. - Using _is_visible() function to support NPCM8XX. - add __poll_t custom. Changes since version 1: - Remove LPC present from the BPC driver. - Modify dt-bindings message header. - Add vendor to the file name. - Modify incorrect spelling. Tomer Maimon (3): dt-bindings: soc: nuvoton: Add NPCM BPC soc: nuvoton: add configuration menu soc: nuvoton: add NPCM BPC driver .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 65 +++ drivers/soc/nuvoton/Kconfig | 16 +- drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 387 ++++++++++++++++++ 4 files changed, 468 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml create mode 100644 drivers/soc/nuvoton/npcm-bpc.c -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 05:28:43 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 20:28:43 +0200 Subject: [PATCH v3 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC In-Reply-To: <20231213182845.3744685-1-tmaimon77@gmail.com> References: <20231213182845.3744685-1-tmaimon77@gmail.com> Message-ID: <20231213182845.3744685-2-tmaimon77@gmail.com> Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post Code (BPC). The NPCM BPC monitoring two configurable I/O addresses written by the host on the bus. Signed-off-by: Tomer Maimon --- .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml diff --git a/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml new file mode 100644 index 000000000000..c04302a1d52b --- /dev/null +++ b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton BMC NPCM BIOS Post Code (BPC) controller + +maintainers: + - Tomer Maimon + +description: + Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O + addresses written by the host on the bus, the capture data stored in + 128-word FIFO. + + NPCM BPC supports capture double words, when using capture + double word only I/O address 1 is monitored. + +properties: + compatible: + items: + - enum: + - nuvoton,npcm845-bpc + - nuvoton,npcm750-bpc + - const: nuvoton,npcm-bpc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + nuvoton,monitor-ports: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: + Contain monitor I/O addresses on the bus, at least one monitor I/O + address required. + + nuvoton,bpc-en-dwcapture: + description: + Set DWCAPTURE bit in BPCFEN register that enable double words capture + according to the first address setting. + type: boolean + +required: + - compatible + - reg + - interrupts + - nuvoton,monitor-ports + +additionalProperties: false + +examples: + - | + #include + #include + + bpc: bpc at f0007040 { + compatible = "nuvoton,npcm750-bpc", "nuvoton,npcm-bpc"; + reg = <0xf0007040 0x20>; + interrupts = ; + nuvoton,monitor-ports = <0x80>; + }; +... -- 2.34.1 From tmaimon77 at gmail.com Thu Dec 14 05:28:45 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Wed, 13 Dec 2023 20:28:45 +0200 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <20231213182845.3744685-1-tmaimon77@gmail.com> References: <20231213182845.3744685-1-tmaimon77@gmail.com> Message-ID: <20231213182845.3744685-4-tmaimon77@gmail.com> Add Nuvoton BMC NPCM BIOS post code (BPC) driver. The NPCM BPC monitoring two configurable I/O address written by the host on the bus. Signed-off-by: Tomer Maimon --- drivers/soc/nuvoton/Kconfig | 9 + drivers/soc/nuvoton/Makefile | 1 + drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 drivers/soc/nuvoton/npcm-bpc.c diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig index d5102f5f0c28..ebd162633942 100644 --- a/drivers/soc/nuvoton/Kconfig +++ b/drivers/soc/nuvoton/Kconfig @@ -2,6 +2,15 @@ menu "NUVOTON SoC drivers" +config NPCM_BPC + tristate "NPCM BIOS Post Code support" + depends on (ARCH_NPCM || COMPILE_TEST) + help + Provides NPCM driver to control the BIOS Post Code + interface which allows the BMC to monitor and save + the data written by the host to an arbitrary I/O port, + the BPC is connected to the host thourgh LPC or eSPI bus. + config WPCM450_SOC tristate "Nuvoton WPCM450 SoC driver" default y if ARCH_WPCM450 diff --git a/drivers/soc/nuvoton/Makefile b/drivers/soc/nuvoton/Makefile index e30317b4e829..c6c96079c6e9 100644 --- a/drivers/soc/nuvoton/Makefile +++ b/drivers/soc/nuvoton/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_NPCM_BPC) += npcm-bpc.o obj-$(CONFIG_WPCM450_SOC) += wpcm450-soc.o diff --git a/drivers/soc/nuvoton/npcm-bpc.c b/drivers/soc/nuvoton/npcm-bpc.c new file mode 100644 index 000000000000..cb5e5a11d6d8 --- /dev/null +++ b/drivers/soc/nuvoton/npcm-bpc.c @@ -0,0 +1,387 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2020 Nuvoton Technology corporation. + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEVICE_NAME "npcm-bpc" + +#define NUM_BPC_CHANNELS 2 +#define DW_PAD_SIZE 3 + +/* BIOS POST Code FIFO Registers */ +#define NPCM_BPCFA2L_REG 0x2 //BIOS POST Code FIFO Address 2 LSB +#define NPCM_BPCFA2M_REG 0x4 //BIOS POST Code FIFO Address 2 MSB +#define NPCM_BPCFEN_REG 0x6 //BIOS POST Code FIFO Enable +#define NPCM_BPCFSTAT_REG 0x8 //BIOS POST Code FIFO Status +#define NPCM_BPCFDATA_REG 0xA //BIOS POST Code FIFO Data +#define NPCM_BPCFMSTAT_REG 0xC //BIOS POST Code FIFO Miscellaneous Status +#define NPCM_BPCFA1L_REG 0x10 //BIOS POST Code FIFO Address 1 LSB +#define NPCM_BPCFA1M_REG 0x12 //BIOS POST Code FIFO Address 1 MSB + +/* BIOS register data */ +#define FIFO_IOADDR1_ENABLE 0x80 +#define FIFO_IOADDR2_ENABLE 0x40 + +/* BPC interface package and structure definition */ +#define BPC_KFIFO_SIZE 0x400 + +/* BPC register data */ +#define FIFO_DATA_VALID 0x80 +#define FIFO_OVERFLOW 0x20 +#define FIFO_READY_INT_ENABLE 0x8 +#define FIFO_DWCAPTURE 0x4 +#define FIFO_ADDR_DECODE 0x1 + +/* Host Reset */ +#define HOST_RESET_INT_ENABLE 0x10 +#define HOST_RESET_CHANGED 0x40 + +struct npcm_bpc_channel { + struct npcm_bpc *data; + struct kfifo fifo; + wait_queue_head_t wq; + bool host_reset; + struct miscdevice miscdev; +}; + +struct npcm_bpc { + void __iomem *base; + struct device *dev; + int irq; + bool en_dwcap; + struct npcm_bpc_channel ch[NUM_BPC_CHANNELS]; +}; + +static struct npcm_bpc_channel *npcm_file_to_ch(struct file *file) +{ + return container_of(file->private_data, struct npcm_bpc_channel, + miscdev); +} + +static ssize_t npcm_bpc_read(struct file *file, char __user *buffer, + size_t count, loff_t *ppos) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + struct npcm_bpc *bpc = chan->data; + unsigned int copied; + int cond_size = 1; + int ret = 0; + + if (bpc->en_dwcap) + cond_size = 3; + + if (kfifo_len(&chan->fifo) < cond_size) { + if (file->f_flags & O_NONBLOCK) + return -EAGAIN; + + ret = wait_event_interruptible + (chan->wq, kfifo_len(&chan->fifo) > cond_size); + if (ret == -ERESTARTSYS) + return -EINTR; + } + + ret = kfifo_to_user(&chan->fifo, buffer, count, &copied); + + return ret ? ret : copied; +} + +static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt) +{ + struct npcm_bpc_channel *chan = npcm_file_to_ch(file); + __poll_t mask = 0; + + poll_wait(file, &chan->wq, pt); + if (!kfifo_is_empty(&chan->fifo)) + mask = (__poll_t)POLLIN; + + if (chan->host_reset) { + mask |= (__poll_t)POLLHUP; + chan->host_reset = false; + } + + return mask; +} + +static const struct file_operations npcm_bpc_fops = { + .owner = THIS_MODULE, + .read = npcm_bpc_read, + .poll = npcm_bpc_poll, + .llseek = noop_llseek, +}; + +static irqreturn_t npcm_bpc_irq(int irq, void *arg) +{ + struct npcm_bpc *bpc = arg; + u8 fifo_st, host_st, data; + bool isr_flag = false; + u8 last_addr_bit = 0; + u8 padzero[3] = {0}; + u8 addr_index = 0; + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + while (FIFO_DATA_VALID & fifo_st) { + /* If dwcapture enabled only channel 0 (FIFO 0) used */ + if (!bpc->en_dwcap) + addr_index = fifo_st & FIFO_ADDR_DECODE; + else + last_addr_bit = fifo_st & FIFO_ADDR_DECODE; + + /* Read data from FIFO to clear interrupt */ + data = ioread8(bpc->base + NPCM_BPCFDATA_REG); + if (kfifo_is_full(&bpc->ch[addr_index].fifo)) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_put(&bpc->ch[addr_index].fifo, data); + if (fifo_st & FIFO_OVERFLOW) + dev_warn(bpc->dev, "BIOS Post Codes FIFO Overflow\n"); + + fifo_st = ioread8(bpc->base + NPCM_BPCFSTAT_REG); + if (bpc->en_dwcap && last_addr_bit) { + if ((fifo_st & FIFO_ADDR_DECODE) || + ((FIFO_DATA_VALID & fifo_st) == 0)) { + while (kfifo_avail(&bpc->ch[addr_index].fifo) < DW_PAD_SIZE) + kfifo_skip(&bpc->ch[addr_index].fifo); + kfifo_in(&bpc->ch[addr_index].fifo, + padzero, DW_PAD_SIZE); + } + } + isr_flag = true; + } + + host_st = ioread8(bpc->base + NPCM_BPCFMSTAT_REG); + if (host_st & HOST_RESET_CHANGED) { + iowrite8(HOST_RESET_CHANGED, + bpc->base + NPCM_BPCFMSTAT_REG); + bpc->ch[addr_index].host_reset = true; + isr_flag = true; + } + + if (isr_flag) { + wake_up_interruptible(&bpc->ch[addr_index].wq); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +static int npcm_bpc_config_irq(struct npcm_bpc *bpc, + struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int rc; + + bpc->irq = platform_get_irq(pdev, 0); + if (bpc->irq < 0) { + dev_err(dev, "get IRQ failed\n"); + return bpc->irq; + } + + rc = devm_request_irq(dev, bpc->irq, + npcm_bpc_irq, IRQF_SHARED, + DEVICE_NAME, bpc); + if (rc < 0) { + dev_warn(dev, "Unable to request IRQ %d\n", bpc->irq); + return rc; + } + + return 0; +} + +static int npcm_enable_bpc(struct npcm_bpc *bpc, struct device *dev, + int channel, u16 host_port) +{ + u8 addr_en, reg_en; + int err; + + init_waitqueue_head(&bpc->ch[channel].wq); + + err = kfifo_alloc(&bpc->ch[channel].fifo, BPC_KFIFO_SIZE, + GFP_KERNEL); + if (err) + return err; + + bpc->ch[channel].miscdev.minor = MISC_DYNAMIC_MINOR; + bpc->ch[channel].miscdev.name = + devm_kasprintf(dev, GFP_KERNEL, "%s%d", DEVICE_NAME, channel); + bpc->ch[channel].miscdev.fops = &npcm_bpc_fops; + bpc->ch[channel].miscdev.parent = dev; + err = misc_register(&bpc->ch[channel].miscdev); + if (err) + return err; + + bpc->ch[channel].data = bpc; + bpc->ch[channel].host_reset = false; + + /* Enable host snoop channel at requested port */ + switch (channel) { + case 0: + addr_en = FIFO_IOADDR1_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA1L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA1M_REG); + break; + case 1: + addr_en = FIFO_IOADDR2_ENABLE; + iowrite8((u8)host_port & 0xFF, + bpc->base + NPCM_BPCFA2L_REG); + iowrite8((u8)(host_port >> 8), + bpc->base + NPCM_BPCFA2M_REG); + break; + default: + return -EINVAL; + } + + if (bpc->en_dwcap) + addr_en = FIFO_DWCAPTURE; + + /* + * Enable FIFO Ready Interrupt, FIFO Capture of I/O addr, + * and Host Reset + */ + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en | addr_en | FIFO_READY_INT_ENABLE | + HOST_RESET_INT_ENABLE, bpc->base + NPCM_BPCFEN_REG); + + return 0; +} + +static void npcm_disable_bpc(struct npcm_bpc *bpc, int channel) +{ + u8 reg_en; + + switch (channel) { + case 0: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + if (bpc->en_dwcap) + iowrite8(reg_en & ~FIFO_DWCAPTURE, + bpc->base + NPCM_BPCFEN_REG); + else + iowrite8(reg_en & ~FIFO_IOADDR1_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + case 1: + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + iowrite8(reg_en & ~FIFO_IOADDR2_ENABLE, + bpc->base + NPCM_BPCFEN_REG); + break; + default: + return; + } + + if (!(reg_en & (FIFO_IOADDR1_ENABLE | FIFO_IOADDR2_ENABLE))) + iowrite8(reg_en & + ~(FIFO_READY_INT_ENABLE | HOST_RESET_INT_ENABLE), + bpc->base + NPCM_BPCFEN_REG); + + kfifo_free(&bpc->ch[channel].fifo); + misc_deregister(&bpc->ch[channel].miscdev); +} + +static int npcm_bpc_probe(struct platform_device *pdev) +{ + struct npcm_bpc *bpc; + struct device *dev; + u32 port; + int err; + + dev = &pdev->dev; + + bpc = devm_kzalloc(dev, sizeof(*bpc), GFP_KERNEL); + if (!bpc) + return -ENOMEM; + + bpc->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(bpc->base)) + return PTR_ERR(bpc->base); + + dev_set_drvdata(&pdev->dev, bpc); + + err = of_property_read_u32_index(dev->of_node, "nuvoton,monitor-ports", + 0, &port); + if (err) { + dev_err(dev, "no monitor ports configured\n"); + return -ENODEV; + } + + bpc->en_dwcap = + of_property_read_bool(dev->of_node, "nuvoton,bpc-en-dwcapture"); + + bpc->dev = dev; + + err = npcm_bpc_config_irq(bpc, pdev); + if (err) + return err; + + err = npcm_enable_bpc(bpc, dev, 0, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 0 failed\n"); + return err; + } + + /* + * Configuration of second BPC channel port is optional + * Double-Word Capture ignoring address 2 + */ + if (!bpc->en_dwcap) { + if (of_property_read_u32_index(dev->of_node, + "nuvoton,monitor-ports", 1, + &port) == 0) { + err = npcm_enable_bpc(bpc, dev, 1, port); + if (err) { + dev_err(dev, "Enable BIOS post code I/O port 1 failed, disable I/O port 0\n"); + npcm_disable_bpc(bpc, 0); + return err; + } + } + } + + pr_info("NPCM BIOS Post Code probe\n"); + + return err; +} + +static int npcm_bpc_remove(struct platform_device *pdev) +{ + struct npcm_bpc *bpc = dev_get_drvdata(&pdev->dev); + u8 reg_en; + + reg_en = ioread8(bpc->base + NPCM_BPCFEN_REG); + + if (reg_en & FIFO_IOADDR1_ENABLE) + npcm_disable_bpc(bpc, 0); + if (reg_en & FIFO_IOADDR2_ENABLE) + npcm_disable_bpc(bpc, 1); + + return 0; +} + +static const struct of_device_id npcm_bpc_match[] = { + { .compatible = "nuvoton,npcm-bpc" }, + { }, +}; + +static struct platform_driver npcm_bpc_driver = { + .driver = { + .name = DEVICE_NAME, + .of_match_table = npcm_bpc_match, + }, + .probe = npcm_bpc_probe, + .remove = npcm_bpc_remove, +}; + +module_platform_driver(npcm_bpc_driver); + +MODULE_DEVICE_TABLE(of, npcm_bpc_match); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_DESCRIPTION("NPCM BIOS post code monitoring device driver"); -- 2.34.1 From geissonator at gmail.com Thu Dec 14 07:43:37 2023 From: geissonator at gmail.com (Andrew Geissler) Date: Wed, 13 Dec 2023 14:43:37 -0600 Subject: Redundant BMC's Message-ID: Greetings, We at IBM are looking at implementing a server with redundant BMC's. The idea of redundant BMC's is that if one fails (software or hardware related), the other BMC takes over and there is no impact to the owner of the server (enterprise, high availability market). One BMC is the "Active" BMC and the other is the "Passive?. High level you have 2 or more chassis's in a single server. 2 of those chassis's have BMC's running OpenBMC. The BMC's negotiate on startup which one will be the Active BMC and which one will be the Passive. Both BMC's have full access to the server hardware (fans, power supplies, VPD chips, ...) but only one can access the hardware at one time (via hardware mux). The Passive BMC will be running a subset of OpenBMC services. As it will need to support firmware update, and other basic features, it will have bmcweb running. But other services like fan or power control would not be running on the Passive. The Active BMC will utilize bmcweb aggregation to provide basic information about the Passive BMC. Server management can only occur via the Active BMC. As the user changes settings (BIOS, certificates, system policy, ...) via the Active BMC, we need to ensure we replicate these settings over to the Passive. We've done a bit of initial exploration into using corosync/pacemaker. It has some potential but also feels a bit heavy for what we need. The thought is that a role change where the Passive BMC becomes the Active BMC and the Active becomes the Passive is mostly driven by our external software managers. There's potential for some cases where the BMC's themselves drive the role changes but most of our use cases are situations where something in the BMC hardware (or its connections to the server) have failed and the BIOS firmware or Redfish management client direct the Passive BMC to become the Active. A roll-our-own data synchronization daemon (utilizing rsync) to monitor for file changes with some basic rules on when to synch (immediate, synch points) doesn't seem all that bad but there's probably a lot of unknown pitfalls something like corosync/pacemaker already handle. Just throwing this out there in case anyone is also working on this or has any opinions on direction here. Thanks, Andrew From joel at jms.id.au Thu Dec 14 09:19:21 2023 From: joel at jms.id.au (Joel Stanley) Date: Thu, 14 Dec 2023 08:49:21 +1030 Subject: [PATCH v1 1/1] ARM: dts: aspeed: Add IEISystems FP5280G3 BMC machine In-Reply-To: <20231213103309.2754291-1-liuxiwei@ieisystem.com> References: <20231213103309.2754291-1-liuxiwei@ieisystem.com> Message-ID: Hi George, On Wed, 13 Dec 2023 at 21:03, George Liu wrote: > > The IEISystems FP5280G3 is a power platform server with an > AST2600-based BMC. > This dts file provides a basic configuration for its OpenBMC > development. > > Signed-off-by: George Liu Upstream lists for review first please. Cheers, Joel > --- > .../aspeed/aspeed-bmc-ieisystems-fp5280g3.dts | 999 ++++++++++++++++++ > 1 file changed, 999 insertions(+) > create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > > diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > new file mode 100644 > index 000000000000..30ee506a88e1 > --- /dev/null > +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > @@ -0,0 +1,999 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (c) 2023, IEISystems Corporation > + > +/dts-v1/; > + > +#include "aspeed-g6.dtsi" > +#include "ibm-power10-dual.dtsi" > +#include "ibm-power10-quad.dtsi" > +#include > +#include > + > +/ { > + model = "FP5280G3 BMC"; > + compatible = "ieisystems,fp5280g3-bmc", "aspeed,ast2600"; > + > + aliases { > + i2c2001 = &i2c2s0ch1; > + i2c2002 = &i2c2s0ch2; > + i2c5000 = &i2c5s0ch0; > + i2c5001 = &i2c5s0ch1; > + i2c5002 = &i2c5s0ch2; > + i2c5003 = &i2c5s0ch3; > + i2c6000 = &i2c6s0ch0; > + i2c6001 = &i2c6s0ch1; > + i2c6002 = &i2c6s0ch2; > + i2c6003 = &i2c6s0ch3; > + i2c6004 = &i2c6s0ch4; > + i2c6005 = &i2c6s0ch5; > + i2c6100 = &i2c6s1ch0; > + i2c6101 = &i2c6s1ch1; > + i2c6200 = &i2c6s2ch0; > + i2c6201 = &i2c6s2ch1; > + i2c12000 = &i2c12s0ch0; > + i2c12001 = &i2c12s0ch1; > + i2c12002 = &i2c12s0ch2; > + i2c12003 = &i2c12s0ch3; > + i2c12100 = &i2c12s1ch0; > + i2c12101 = &i2c12s1ch1; > + i2c12102 = &i2c12s1ch2; > + i2c13000 = &i2c13s0ch0; > + i2c13001 = &i2c13s0ch1; > + i2c13002 = &i2c13s0ch2; > + i2c13003 = &i2c13s0ch3; > + }; > + > + chosen { > + stdout-path = &uart5; > + bootargs = "console=ttyS4,115200n8 earlycon"; > + }; > + > + memory at 80000000 { > + device_type = "memory"; > + reg = <0x80000000 0x80000000>; > + }; > + > + reserved-memory { > + #address-cells = <1>; > + #size-cells = <1>; > + ranges; > + > + ramoops at b3e00000 { > + compatible = "ramoops"; > + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ > + record-size = <0x8000>; > + console-size = <0x8000>; > + ftrace-size = <0x8000>; > + pmsg-size = <0x8000>; > + max-reason = <3>; /* KMSG_DUMP_EMERG */ > + }; > + > + /* LPC FW cycle bridge region requires natural alignment */ > + flash_memory: region at b4000000 { > + no-map; > + reg = <0xb4000000 0x04000000>; /* 64M */ > + }; > + > + /* VGA region is dictated by hardware strapping */ > + vga_memory: region at bf000000 { > + no-map; > + compatible = "shared-dma-pool"; > + reg = <0xbf000000 0x01000000>; /* 16M */ > + }; > + > + video_engine_memory: jpegbuffer { > + size = <0x02000000>; /* 32M */ > + alignment = <0x01000000>; > + compatible = "shared-dma-pool"; > + reusable; > + }; > + gfx_memory: framebuffer { > + size = <0x01000000>; > + alignment = <0x01000000>; > + compatible = "shared-dma-pool"; > + reusable; > + }; > + }; > + > + iio-hwmon { > + compatible = "iio-hwmon"; > + io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, > + <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, > + <&adc0 7>, <&adc1 0>; > + }; > + > + gpio-keys { > + compatible = "gpio-keys"; > + > + cpld { > + label = "cpld"; > + gpios = <&gpio0 ASPEED_GPIO(S, 4) GPIO_ACTIVE_HIGH>; > + linux,code = ; > + }; > + }; > + > + leds { > + compatible = "gpio-leds"; > + > + bmc-heart-beat { > + gpios = <&gpio0 ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; > + default-state = "keep"; > + }; > + > + bmc-init-ok { > + gpios = <&gpio0 ASPEED_GPIO(R, 5) GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + chassis-power-on { > + gpios = <&gpio0 ASPEED_GPIO(Q, 3) GPIO_ACTIVE_LOW>; > + default-state = "keep"; > + }; > + > + bmc-bootup { > + gpios = <&gpio0 ASPEED_GPIO(S, 0) GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + fan-watchdog { > + label = "fan-watchdog"; > + gpios = <&gpio0 ASPEED_GPIO(E, 0) GPIO_ACTIVE_LOW>; > + linux,default-trigger = "timer"; > + }; > + }; > + > +}; > + > +&adc0 { > + status = "okay"; > + aspeed,int-vref-microvolt = <2500000>; > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_adc0_default > + &pinctrl_adc1_default > + &pinctrl_adc2_default > + &pinctrl_adc3_default > + &pinctrl_adc4_default > + &pinctrl_adc5_default > + &pinctrl_adc6_default > + &pinctrl_adc7_default>; > +}; > + > +&adc1 { > + status = "okay"; > + aspeed,int-vref-microvolt = <2500000>; > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_adc8_default>; > +}; > + > +&gpio0 { > + gpio-line-names = > + /*A0-A7*/ "","","","","","","","", > + /*B0-B7*/ "","","","","","","","", > + /*C0-C7*/ "","","","","","","","", > + /*D0-D7*/ "","","","","","","","", > + /*E0-E7*/ "","","","","","","","", > + /*F0-F7*/ "","","","","","","","", > + /*G0-G7*/ "","","","","","","","", > + /*H0-H7*/ "","","","","","","","", > + /*I0-I7*/ "","","","","","","","", > + /*J0-J7*/ "","","","","","","","", > + /*K0-K7*/ "","","","","","","","", > + /*L0-L7*/ "","","","","","","","", > + /*M0-M7*/ "","","","","","","","", > + /*N0-N7*/ "","","","","SCM_CPLD_UPDATE_HITLESS","","","", > + /*O0-O7*/ "","","","","","","","", > + /*P0-P7*/ "","","","","","","","", > + /*Q0-Q7*/ "","","","","","FM_PSU1_PRSNT_N","FM_PSU0_PRSNT_N","MB_CPLD_UPDATE_HITLESS", > + /*R0-R7*/ "","","","checkstop","","","power-chassis-control","power-button", > + /*S0-S7*/ "","","POSTFINISH","","","FM_BATTERY_SENSE_EN","","", > + /*T0-T7*/ "","","","","","","","", > + /*U0-U7*/ "","","","","","","","", > + /*V0-V7*/ "","","","","power-chassis-good","","","", > + /*W0-W7*/ "","","","","","","","", > + /*X0-X7*/ "","","","","","","","", > + /*Y0-Y7*/ "","","","","","","","", > + /*Z0-Z7*/ "","","","","","","",""; > +}; > + > +&mdio1 { > + status = "okay"; > + > + ethphy1: ethernet-phy at 0 { > + compatible = "ethernet-phy-ieee802.3-c22"; > + reg = <0>; > + }; > +}; > + > +&mac2 { > + status = "okay"; > + > + phy-mode = "rgmii"; > + phy-handle = <ðphy1>; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_rgmii3_default>; > +}; > + > +&mac3 { > + status = "okay"; > + > + phy-mode = "rmii"; > + use-ncsi; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_rmii4_default>; > +}; > + > +&emmc_controller { > + status = "okay"; > +}; > + > +&pinctrl_emmc_default { > + bias-disable; > +}; > + > +&emmc { > + status = "okay"; > + clk-phase-mmc-hs200 = <180>, <180>; > +}; > + > +&fsim0 { > + cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 4) GPIO_ACTIVE_LOW>; > +} > + > +&i2c1 { > + status = "okay"; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "Sys_Outlet_Temp"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > +}; > + > +&i2c2 { > + status = "okay"; > + tmp112 at 40{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "Inlet_Temp"; > + }; > + > + pca9548 at 70{ > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + i2c2s0ch1: i2c at 1{ > + reg = <1>; > + tmp112 at 49{ > + compatible = "ti,tmp112"; > + reg = <0x49>; > + label = "PSU_Inlet0_Temp"; > + }; > + tmp112 at 4a{ > + compatible = "ti,tmp112"; > + reg = <0x4a>; > + label = "PSU_Inlet1_Temp"; > + }; > + }; > + i2c2s0ch2: i2c at 2{ > + reg = <2>; > + tmp112 at 49{ > + compatible = "ti,tmp112"; > + reg = <0x49>; > + label = "L_OCP_ZONE_Temp"; > + }; > + tmp112 at 4a{ > + compatible = "ti,tmp112"; > + reg = <0x4a>; > + label = "R_OCP_ZONE_Temp"; > + }; > + }; > + }; > + > + pca0:pca9555 at 20 { > + compatible = "nxp,pca9555"; > + reg = <0x20>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "OCP0_CABLE_PRSNT_N", "OCP0_BIF2_N", > + "OCP0_BIF1_N", "OCP0_BIF0_N", > + "OCP0_CARD_PRSNTB3_ISO_N", "OCP0_CARD_PRSNTB2_ISO_N", > + "OCP0_CARD_PRSNTB1_ISO_N", "OCP0_CARD_PRSNTB0_ISO_N", > + "PE_MCIO0_BP_ID0_Q_N", "PE_MCIO0_BP_ID1_Q_N", > + "PE_MCIO1_BP_ID0_Q_N", "PE_MCIO1_BP_ID1_Q_N", > + "PE_MCIO2_BP_ID0_Q_N", "PE_MCIO2_BP_ID1_Q_N", > + "RISER0_PRSNT_N", "REAR_HDD_PRSNT_N"; > + }; > + pca1:pca9555 at 21 { > + compatible = "nxp,pca9555"; > + reg = <0x21>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "OCP1_CABLE_PRSNT_N", "OCP1_BIF2_N", > + "OCP1_BIF1_N", "OCP1_BIF0_N", > + "OCP1_CARD_PRSNTB3_ISO_N", "OCP1_CARD_PRSNTB2_ISO_N", > + "OCP1_CARD_PRSNTB1_ISO_N", "OCP1_CARD_PRSNTB0_ISO_N", > + "PE_MCIO3_BP_ID0_Q_N", "PE_MCIO3_BP_ID1_Q_N", > + "PE_MCIO4_BP_ID0_Q_N", "PE_MCIO4_BP_ID1_Q_N", > + "PE_MCIO5_BP_ID0_Q_N", "PE_MCIO5_BP_ID1_Q_N", > + "RISER2_PRSNT_N", "RISER1_PRSNT_N"; > + }; > + pca2:pca9555 at 22 { > + compatible = "nxp,pca9555"; > + reg = <0x22>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER2_BOARD_ID1_N", "RISER2_BOARD_ID0_N", > + "RISER1_BOARD_ID2_N", "RISER1_BOARD_ID1_N", > + "RISER1_BOARD_ID0_N", "RISER0_BOARD_ID2_N", > + "RISER0_BOARD_ID1_N", "RISER0_BOARD_ID0_N", > + "PE_MCIO6_BP_ID0_Q_N", "PE_MCIO6_BP_ID1_Q_N", > + "PE_MCIO7_BP_ID0_Q_N", "PE_MCIO7_BP_ID1_Q_N", > + "PE_MCIO8_BP_ID0_Q_N", "PE_MCIO8_BP_ID1_Q_N", > + "PE_MCIO9_BP_ID0_Q_N", "PE_MCIO9_BP_ID0_Q_N"; > + }; > + pca3:pca9555 at 23 { > + compatible = "nxp,pca9555"; > + reg = <0x23>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", > + "", "", > + "", "", > + "", "RISER2_BOARD_ID2_N", > + "PE_MCIO10_BP_ID0_Q_N", "PE_MCIO10_BP_ID1_Q_N", > + "PE_MCIO7_BP_ID11_Q_N", "PE_MCIO11_BP_ID1_Q_N", > + "PE_MCIO12_BP_ID0_Q_N", "PE_MCIO12_BP_ID1_Q_N", > + "PE_MCIO13_BP_ID0_Q_N", "PE_MCIO13_BP_ID0_Q_N"; > + }; > +}; > + > +&i2c3 { > + status = "okay"; > + pca9548 at 70 { > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + }; > +}; > + > +&i2c5 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c5s0ch0: i2c at 0 { > + reg = <0>; > + status = "okay"; > + cpu0vdda at 60 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x60>; > + }; > + cpu0vddb at 61 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x61>; > + }; > + cpu0vdn at 72 { > + compatible = "infineon,ir35221"; > + reg = <0x72>; > + }; > + cpu0vio at 73 { > + compatible = "infineon,ir35221"; > + reg = <0x73>; > + }; > + cpu0vpci at 74 { > + compatible = "infineon,ir35221"; > + reg = <0x74>; > + }; > + }; > + i2c5s0ch1: i2c at 1{ > + reg = <1>; > + status = "okay"; > + cpu1vddc at 60 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x60>; > + }; > + cpu1vddd at 61 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x61>; > + }; > + cpu1vdn at 72 { > + compatible = "infineon,ir35221"; > + reg = <0x72>; > + }; > + cpu1vio at 73 { > + compatible = "infineon,ir35221"; > + reg = <0x73>; > + }; > + cpu1vpci at 74 { > + compatible = "infineon,ir35221"; > + reg = <0x74>; > + }; > + }; > + i2c5s0ch2: i2c at 2{ > + reg = <2>; > + status = "okay"; > + pxe1610 at 6c { > + compatible = "infineon,pxe1610"; > + reg = <0x6c>; > + }; > + rdimm at 74 { > + compatible = "infineon,pxe1610"; > + reg = <0x74>; > + }; > + mdimm at 54 { > + compatible = "infineon,pxe1610"; > + reg = <0x5A>; > + }; > + ldimm at 44 { > + compatible = "infineon,pxe1610"; > + reg = <0x5C>; > + }; > + }; > + i2c5s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > +}; > + > +&i2c6 { > + /* SMB_TEMPSENSOR_STBY_LVC3_R */ > + multi-master; > + status = "okay"; > + > + i2c-switch at 70 { > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + #address-cells = <1>; > + #size-cells = <0>; > + > + i2c6s0ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + > + > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch2: i2c at 2 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <2>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch3: i2c at 3 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <3>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + > + pca9548 at 71 { > + compatible = "nxp,pca9548"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + > + i2c6s1ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + }; > + i2c6s1ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + }; > + }; > + }; > + i2c6s0ch4: i2c at 4 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <4>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + > + pca9548 at 71 { > + compatible = "nxp,pca9548"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + > + i2c6s2ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + }; > + i2c6s2ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + }; > + }; > + }; > + i2c6s0ch5: i2c at 5 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <5>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + }; > +}; > + > +&i2c7 { > + status = "okay"; > + adc128d818 at 1d{ > + compatible = "ti,adc128d818"; > + reg = <0x1d>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 1e{ > + compatible = "ti,adc128d818"; > + reg = <0x1e>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 1f{ > + compatible = "ti,adc128d818"; > + reg = <0x1f>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2d{ > + compatible = "ti,adc128d818"; > + reg = <0x2d>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2e{ > + compatible = "ti,adc128d818"; > + reg = <0x2e>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2f{ > + compatible = "ti,adc128d818"; > + reg = <0x2f>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 35{ > + compatible = "ti,adc128d818"; > + reg = <0x35>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 36{ > + compatible = "ti,adc128d818"; > + reg = <0x36>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 37{ > + compatible = "ti,adc128d818"; > + reg = <0x37>; > + ti,mode = /bits/ 8 <0x01>; > + }; > +}; > + > +&i2c8 { > + status = "okay"; > + nct7362 at 20 { > + compatible = "nuvoton,nct7362"; > + device-active-gpios = <&gpio0 ASPEED_GPIO(N, 5) GPIO_ACTIVE_HIGH>; > + reg = <0x20>; > + }; > + > + nct7362 at 22 { > + compatible = "nuvoton,nct7362"; > + device-active-gpios = <&gpio0 ASPEED_GPIO(N, 5) GPIO_ACTIVE_HIGH>; > + reg = <0x22>; > + }; > + > + pca9555 at 24{ > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + #address-cells = <1>; > + #size-cells = <0>; > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "FAN_PRSNT5_D_N", "FAN_PRSNT4_D_N", > + "FAN_PRSNT3_D_N", "FAN_PRSNT2_D_N", > + "FAN_PRSNT1_D_N", "FAN_PRSNT0_D_N", > + "", "", > + "", "", "", "", > + "", "", "", ""; > + }; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > + > +}; > + > +&i2c9 { > + status = "okay"; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > +}; > + > +&i2c10 { > + status = "okay"; > + pca9555 at 20 { > + compatible = "nxp,pca9555"; > + reg = <0x20>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "DIMM0_FAULT", "DIMM3_FAULT", > + "DIMM2_FAULT", "DIMM1_FAULT", > + "DIMM4_FAULT", "DIMM5_FAULT", > + "DIMM6_FAULT", "DIMM7_FAULT", > + "DIMM8_FAULT", "DIMM11_FAULT", > + "DIMM10_FAULT", "DIMM9_FAULT", > + "DIMM12_FAULT", "DIMM13_FAULT", > + "DIMM14_FAULT", "DIMM15_FAULT"; > + }; > + > + pca9555 at 22 { > + compatible = "nxp,pca9555"; > + reg = <0x22>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", "", "", "OCP0_PRSNT_N", "", "", "", > + "", "", "", "", "", "", "", ""; > + }; > + > + pca9555 at 23 { > + compatible = "nxp,pca9555"; > + reg = <0x23>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", "", "", "OCP1_PRSNT_N", "", "", "", > + "", "", "", "", "", "", "", ""; > + }; > +}; > + > +&i2c11 { > + status = "okay"; > + bus-timeout-ms = <100>; > + bus-recover-timeout-ms = <10>; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > +}; > + > +&i2c12 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c-mux-idle-disconnect; > + i2c12s0ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_0"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER0_BOARD_ID7", "RISER0_BOARD_ID6", > + "RISER0_BOARD_ID5", "RISER0_BOARD_ID4", > + "RISER0_BOARD_ID3", "RISER0_BOARD_ID2", > + "RISER0_BOARD_ID1", "RISER0_BOARD_ID0", > + "RISER0_SLOT2_PRSNT", "RISER0_SLOT1_PRSNT_X8", > + "RISER0_SLOT0_PRSNT_X8", "RISER0_SLOT1_PRSNT_X16", > + "RISER0_SLOT0_PRSNT_X16", "", "", ""; > + }; > + }; > + i2c12s0ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c12s0ch2: i2c at 2{ > + reg = <2>; > + }; > + i2c12s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > + > + pca9546 at 71{ > + compatible = "nxp,pca9546"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + i2c12s1ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_2"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER2_BOARD_ID0", "RISER2_BOARD_ID1", > + "RISER2_BOARD_ID2", "RISER2_BOARD_ID3", > + "RISER2_BOARD_ID4", "RISER2_BOARD_ID5", > + "RISER2_BOARD_ID6", "RISER2_BOARD_ID7", > + "RISER2_SLOT0_PRSNT", "RISER2_SLOT1_PRSNT", > + "", "", "", "", "", ""; > + }; > + }; > + i2c12s1ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c12s1ch2: i2c at 2{ > + reg = <2>; > + }; > + }; > +}; > + > +&i2c13 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c-mux-idle-disconnect; > + i2c13s0ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_1"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER1_BOARD_ID7", "RISER1_BOARD_ID6", > + "RISER1_BOARD_ID5", "RISER1_BOARD_ID4", > + "RISER1_BOARD_ID3", "RISER1_BOARD_ID2", > + "RISER1_BOARD_ID1", "RISER1_BOARD_ID0", > + "RISER1_SLOT2_PRSNT", "RISER1_SLOT1_PRSNT_X8", > + "RISER1_SLOT0_PRSNT_X8", "RISER1_SLOT1_PRSNT_X16", > + "RISER1_SLOT0_PRSNT_X16", "", "", ""; > + }; > + }; > + i2c13s0ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c13s0ch2: i2c at 2{ > + reg = <2>; > + }; > + i2c13s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > +}; > + > +&i2c14 { > + status = "okay"; > + idt1339 at 68{ > + compatible = "renesas,idt1339"; > + reg = <0x68>; > + }; > +}; > + > +&i2c15 { > + status = "okay"; > +}; > + > +&ibt { > + status = "okay"; > +}; > + > +&uart1 { > + status = "okay"; > +}; > + > +&vuart1 { > + status = "okay"; > +}; > + > +&vuart2 { > + status = "okay"; > +}; > + > +&lpc_ctrl { > + status = "okay"; > + memory-region = <&flash_memory>; > +}; > + > +&wdt1 { > + status = "okay"; > + aspeed,reset-mask1 = <0x20f1ff1>; > +}; > + > +&kcs2 { > + status = "okay"; > + aspeed,lpc-io-reg = <0xca8 0xcac>; > +}; > + > +&kcs3 { > + status = "okay"; > + aspeed,lpc-io-reg = <0xca2>; > + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; > +}; > + > +&pcieh { > + status = "okay"; > +}; > + > +&mctp { > + status = "okay"; > +}; > + > +&bmc_dev { > + status = "okay"; > +}; > + > +&vhub { > + status = "okay"; > +}; > + > +&video { > + status = "okay"; > + memory-region = <&video_engine_memory>; > +}; > + > +&gfx { > + status = "okay"; > + memory-region = <&gfx_memory>; > +}; > -- > 2.34.1 > From conor at kernel.org Wed Dec 13 03:18:43 2023 From: conor at kernel.org (Conor Dooley) Date: Tue, 12 Dec 2023 16:18:43 +0000 Subject: [PATCH v2 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC In-Reply-To: <20231212100703.3374555-2-tmaimon77@gmail.com> References: <20231212100703.3374555-1-tmaimon77@gmail.com> <20231212100703.3374555-2-tmaimon77@gmail.com> Message-ID: <20231212-uncut-sixfold-9359b141b149@spud> On Tue, Dec 12, 2023 at 12:07:01PM +0200, Tomer Maimon wrote: > Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post > Code (BPC). > > The NPCM BPC monitoring two configurable I/O addresses written by the > host on the bus. > > Signed-off-by: Tomer Maimon > --- > .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 63 +++++++++++++++++++ > 1 file changed, 63 insertions(+) > create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml > > diff --git a/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml > new file mode 100644 > index 000000000000..30033cdac8f5 > --- /dev/null > +++ b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml > @@ -0,0 +1,63 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Nuvoton BMC NPCM BIOS Post Code (bpc) controller > + > +maintainers: > + - Tomer Maimon > + > +description: > + Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O > + addresses written by the host on the bus, the capture data stored in > + 128-word FIFO. > + > + NPCM BPC supports capture double words, when using capture > + double word only I/O address 1 is monitored. > + > +properties: > + compatible: > + enum: > + - nuvoton,npcm750-bpc > + - nuvoton,npcm845-bpc > + > + reg: > + maxItems: 1 > + > + interrupts: > + maxItems: 1 > + > + nuvoton,monitor-ports: > + $ref: /schemas/types.yaml#/definitions/uint32-array > + description: > + Contain monitor I/O addresses on the bus, at least one monitor I/O > + address required. > + > + nuvoton,bpc-en-dwcapture: > + description: > + If present, Enable FIFO capture of the DWord address according to > + one address setting. This sounds like something you can either infer from the compatible or is determining software policy. A more detailed explanation/justification is required here. Thanks, Conor. > + type: boolean > + > +required: > + - compatible > + - reg > + - interrupts > + - nuvoton,monitor-ports > + > +additionalProperties: false > + > +examples: > + - | > + #include > + #include > + > + bpc: bpc at f0007040 { > + compatible = "nuvoton,npcm750-bpc"; > + reg = <0xf0007040 0x20>; > + interrupts = ; > + nuvoton,monitor-ports = <0x80>; > + }; > +... > -- > 2.34.1 > > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: not available URL: From wangzq.jn at gmail.com Thu Dec 14 13:11:44 2023 From: wangzq.jn at gmail.com (John Wang) Date: Thu, 14 Dec 2023 10:11:44 +0800 Subject: [PATCH v1 1/1] ARM: dts: aspeed: Add IEISystems FP5280G3 BMC machine In-Reply-To: <20231213103309.2754291-1-liuxiwei@ieisystem.com> References: <20231213103309.2754291-1-liuxiwei@ieisystem.com> Message-ID: George Liu ?2023?12?13??? 18:33??? > > The IEISystems FP5280G3 is a power platform server with an > AST2600-based BMC. > This dts file provides a basic configuration for its OpenBMC > development. > > Signed-off-by: George Liu > --- > .../aspeed/aspeed-bmc-ieisystems-fp5280g3.dts | 999 ++++++++++++++++++ > 1 file changed, 999 insertions(+) > create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > > diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > new file mode 100644 > index 000000000000..30ee506a88e1 > --- /dev/null > +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > @@ -0,0 +1,999 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (c) 2023, IEISystems Corporation > + > +/dts-v1/; > + > +#include "aspeed-g6.dtsi" > +#include "ibm-power10-dual.dtsi" > +#include "ibm-power10-quad.dtsi" > +#include > +#include > + > +/ { > + model = "FP5280G3 BMC"; > + compatible = "ieisystems,fp5280g3-bmc", "aspeed,ast2600"; > + > + aliases { > + i2c2001 = &i2c2s0ch1; > + i2c2002 = &i2c2s0ch2; > + i2c5000 = &i2c5s0ch0; > + i2c5001 = &i2c5s0ch1; > + i2c5002 = &i2c5s0ch2; > + i2c5003 = &i2c5s0ch3; > + i2c6000 = &i2c6s0ch0; > + i2c6001 = &i2c6s0ch1; > + i2c6002 = &i2c6s0ch2; > + i2c6003 = &i2c6s0ch3; > + i2c6004 = &i2c6s0ch4; > + i2c6005 = &i2c6s0ch5; > + i2c6100 = &i2c6s1ch0; > + i2c6101 = &i2c6s1ch1; > + i2c6200 = &i2c6s2ch0; > + i2c6201 = &i2c6s2ch1; > + i2c12000 = &i2c12s0ch0; > + i2c12001 = &i2c12s0ch1; > + i2c12002 = &i2c12s0ch2; > + i2c12003 = &i2c12s0ch3; > + i2c12100 = &i2c12s1ch0; > + i2c12101 = &i2c12s1ch1; > + i2c12102 = &i2c12s1ch2; > + i2c13000 = &i2c13s0ch0; > + i2c13001 = &i2c13s0ch1; > + i2c13002 = &i2c13s0ch2; > + i2c13003 = &i2c13s0ch3; > + }; > + > + chosen { > + stdout-path = &uart5; > + bootargs = "console=ttyS4,115200n8 earlycon"; > + }; > + > + memory at 80000000 { > + device_type = "memory"; > + reg = <0x80000000 0x80000000>; > + }; > + > + reserved-memory { > + #address-cells = <1>; > + #size-cells = <1>; > + ranges; > + > + ramoops at b3e00000 { > + compatible = "ramoops"; > + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ > + record-size = <0x8000>; > + console-size = <0x8000>; > + ftrace-size = <0x8000>; > + pmsg-size = <0x8000>; > + max-reason = <3>; /* KMSG_DUMP_EMERG */ > + }; > + > + /* LPC FW cycle bridge region requires natural alignment */ > + flash_memory: region at b4000000 { > + no-map; > + reg = <0xb4000000 0x04000000>; /* 64M */ > + }; > + > + /* VGA region is dictated by hardware strapping */ > + vga_memory: region at bf000000 { > + no-map; > + compatible = "shared-dma-pool"; > + reg = <0xbf000000 0x01000000>; /* 16M */ > + }; > + > + video_engine_memory: jpegbuffer { > + size = <0x02000000>; /* 32M */ > + alignment = <0x01000000>; > + compatible = "shared-dma-pool"; > + reusable; > + }; > + gfx_memory: framebuffer { > + size = <0x01000000>; > + alignment = <0x01000000>; > + compatible = "shared-dma-pool"; > + reusable; > + }; > + }; > + > + iio-hwmon { > + compatible = "iio-hwmon"; > + io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, > + <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, > + <&adc0 7>, <&adc1 0>; > + }; > + > + gpio-keys { > + compatible = "gpio-keys"; > + > + cpld { > + label = "cpld"; > + gpios = <&gpio0 ASPEED_GPIO(S, 4) GPIO_ACTIVE_HIGH>; > + linux,code = ; > + }; > + }; > + > + leds { > + compatible = "gpio-leds"; > + > + bmc-heart-beat { > + gpios = <&gpio0 ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; > + default-state = "keep"; > + }; > + > + bmc-init-ok { > + gpios = <&gpio0 ASPEED_GPIO(R, 5) GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + chassis-power-on { > + gpios = <&gpio0 ASPEED_GPIO(Q, 3) GPIO_ACTIVE_LOW>; > + default-state = "keep"; > + }; > + > + bmc-bootup { > + gpios = <&gpio0 ASPEED_GPIO(S, 0) GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + fan-watchdog { > + label = "fan-watchdog"; > + gpios = <&gpio0 ASPEED_GPIO(E, 0) GPIO_ACTIVE_LOW>; > + linux,default-trigger = "timer"; > + }; > + }; > + > +}; > + > +&adc0 { > + status = "okay"; > + aspeed,int-vref-microvolt = <2500000>; > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_adc0_default > + &pinctrl_adc1_default > + &pinctrl_adc2_default > + &pinctrl_adc3_default > + &pinctrl_adc4_default > + &pinctrl_adc5_default > + &pinctrl_adc6_default > + &pinctrl_adc7_default>; > +}; > + > +&adc1 { > + status = "okay"; > + aspeed,int-vref-microvolt = <2500000>; > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_adc8_default>; > +}; > + > +&gpio0 { > + gpio-line-names = > + /*A0-A7*/ "","","","","","","","", > + /*B0-B7*/ "","","","","","","","", > + /*C0-C7*/ "","","","","","","","", > + /*D0-D7*/ "","","","","","","","", > + /*E0-E7*/ "","","","","","","","", > + /*F0-F7*/ "","","","","","","","", > + /*G0-G7*/ "","","","","","","","", > + /*H0-H7*/ "","","","","","","","", > + /*I0-I7*/ "","","","","","","","", > + /*J0-J7*/ "","","","","","","","", > + /*K0-K7*/ "","","","","","","","", > + /*L0-L7*/ "","","","","","","","", > + /*M0-M7*/ "","","","","","","","", > + /*N0-N7*/ "","","","","SCM_CPLD_UPDATE_HITLESS","","","", > + /*O0-O7*/ "","","","","","","","", > + /*P0-P7*/ "","","","","","","","", > + /*Q0-Q7*/ "","","","","","FM_PSU1_PRSNT_N","FM_PSU0_PRSNT_N","MB_CPLD_UPDATE_HITLESS", > + /*R0-R7*/ "","","","checkstop","","","power-chassis-control","power-button", > + /*S0-S7*/ "","","POSTFINISH","","","FM_BATTERY_SENSE_EN","","", > + /*T0-T7*/ "","","","","","","","", > + /*U0-U7*/ "","","","","","","","", > + /*V0-V7*/ "","","","","power-chassis-good","","","", > + /*W0-W7*/ "","","","","","","","", > + /*X0-X7*/ "","","","","","","","", > + /*Y0-Y7*/ "","","","","","","","", > + /*Z0-Z7*/ "","","","","","","",""; > +}; > + > +&mdio1 { > + status = "okay"; > + > + ethphy1: ethernet-phy at 0 { > + compatible = "ethernet-phy-ieee802.3-c22"; > + reg = <0>; > + }; > +}; > + > +&mac2 { > + status = "okay"; > + > + phy-mode = "rgmii"; > + phy-handle = <ðphy1>; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_rgmii3_default>; > +}; > + > +&mac3 { > + status = "okay"; > + > + phy-mode = "rmii"; > + use-ncsi; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_rmii4_default>; > +}; > + > +&emmc_controller { > + status = "okay"; > +}; > + > +&pinctrl_emmc_default { > + bias-disable; > +}; > + > +&emmc { > + status = "okay"; > + clk-phase-mmc-hs200 = <180>, <180>; > +}; > + > +&fsim0 { > + cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 4) GPIO_ACTIVE_LOW>; > +} > + > +&i2c1 { > + status = "okay"; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "Sys_Outlet_Temp"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > +}; > + > +&i2c2 { > + status = "okay"; > + tmp112 at 40{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "Inlet_Temp"; > + }; > + > + pca9548 at 70{ > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + i2c2s0ch1: i2c at 1{ > + reg = <1>; > + tmp112 at 49{ > + compatible = "ti,tmp112"; > + reg = <0x49>; > + label = "PSU_Inlet0_Temp"; > + }; > + tmp112 at 4a{ > + compatible = "ti,tmp112"; > + reg = <0x4a>; > + label = "PSU_Inlet1_Temp"; > + }; > + }; > + i2c2s0ch2: i2c at 2{ > + reg = <2>; > + tmp112 at 49{ > + compatible = "ti,tmp112"; > + reg = <0x49>; > + label = "L_OCP_ZONE_Temp"; > + }; > + tmp112 at 4a{ > + compatible = "ti,tmp112"; > + reg = <0x4a>; > + label = "R_OCP_ZONE_Temp"; > + }; > + }; > + }; > + > + pca0:pca9555 at 20 { > + compatible = "nxp,pca9555"; > + reg = <0x20>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "OCP0_CABLE_PRSNT_N", "OCP0_BIF2_N", > + "OCP0_BIF1_N", "OCP0_BIF0_N", > + "OCP0_CARD_PRSNTB3_ISO_N", "OCP0_CARD_PRSNTB2_ISO_N", > + "OCP0_CARD_PRSNTB1_ISO_N", "OCP0_CARD_PRSNTB0_ISO_N", > + "PE_MCIO0_BP_ID0_Q_N", "PE_MCIO0_BP_ID1_Q_N", > + "PE_MCIO1_BP_ID0_Q_N", "PE_MCIO1_BP_ID1_Q_N", > + "PE_MCIO2_BP_ID0_Q_N", "PE_MCIO2_BP_ID1_Q_N", > + "RISER0_PRSNT_N", "REAR_HDD_PRSNT_N"; > + }; > + pca1:pca9555 at 21 { > + compatible = "nxp,pca9555"; > + reg = <0x21>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "OCP1_CABLE_PRSNT_N", "OCP1_BIF2_N", > + "OCP1_BIF1_N", "OCP1_BIF0_N", > + "OCP1_CARD_PRSNTB3_ISO_N", "OCP1_CARD_PRSNTB2_ISO_N", > + "OCP1_CARD_PRSNTB1_ISO_N", "OCP1_CARD_PRSNTB0_ISO_N", > + "PE_MCIO3_BP_ID0_Q_N", "PE_MCIO3_BP_ID1_Q_N", > + "PE_MCIO4_BP_ID0_Q_N", "PE_MCIO4_BP_ID1_Q_N", > + "PE_MCIO5_BP_ID0_Q_N", "PE_MCIO5_BP_ID1_Q_N", > + "RISER2_PRSNT_N", "RISER1_PRSNT_N"; > + }; > + pca2:pca9555 at 22 { > + compatible = "nxp,pca9555"; > + reg = <0x22>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER2_BOARD_ID1_N", "RISER2_BOARD_ID0_N", > + "RISER1_BOARD_ID2_N", "RISER1_BOARD_ID1_N", > + "RISER1_BOARD_ID0_N", "RISER0_BOARD_ID2_N", > + "RISER0_BOARD_ID1_N", "RISER0_BOARD_ID0_N", > + "PE_MCIO6_BP_ID0_Q_N", "PE_MCIO6_BP_ID1_Q_N", > + "PE_MCIO7_BP_ID0_Q_N", "PE_MCIO7_BP_ID1_Q_N", > + "PE_MCIO8_BP_ID0_Q_N", "PE_MCIO8_BP_ID1_Q_N", > + "PE_MCIO9_BP_ID0_Q_N", "PE_MCIO9_BP_ID0_Q_N"; > + }; > + pca3:pca9555 at 23 { > + compatible = "nxp,pca9555"; > + reg = <0x23>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", > + "", "", > + "", "", > + "", "RISER2_BOARD_ID2_N", > + "PE_MCIO10_BP_ID0_Q_N", "PE_MCIO10_BP_ID1_Q_N", > + "PE_MCIO7_BP_ID11_Q_N", "PE_MCIO11_BP_ID1_Q_N", > + "PE_MCIO12_BP_ID0_Q_N", "PE_MCIO12_BP_ID1_Q_N", > + "PE_MCIO13_BP_ID0_Q_N", "PE_MCIO13_BP_ID0_Q_N"; > + }; > +}; > + > +&i2c3 { > + status = "okay"; > + pca9548 at 70 { > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + }; > +}; > + > +&i2c5 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c5s0ch0: i2c at 0 { > + reg = <0>; > + status = "okay"; > + cpu0vdda at 60 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x60>; > + }; > + cpu0vddb at 61 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x61>; > + }; > + cpu0vdn at 72 { > + compatible = "infineon,ir35221"; > + reg = <0x72>; > + }; > + cpu0vio at 73 { > + compatible = "infineon,ir35221"; > + reg = <0x73>; > + }; > + cpu0vpci at 74 { > + compatible = "infineon,ir35221"; > + reg = <0x74>; > + }; > + }; > + i2c5s0ch1: i2c at 1{ > + reg = <1>; > + status = "okay"; > + cpu1vddc at 60 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x60>; > + }; > + cpu1vddd at 61 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x61>; > + }; > + cpu1vdn at 72 { > + compatible = "infineon,ir35221"; > + reg = <0x72>; > + }; > + cpu1vio at 73 { > + compatible = "infineon,ir35221"; > + reg = <0x73>; > + }; > + cpu1vpci at 74 { > + compatible = "infineon,ir35221"; > + reg = <0x74>; > + }; > + }; > + i2c5s0ch2: i2c at 2{ > + reg = <2>; > + status = "okay"; > + pxe1610 at 6c { > + compatible = "infineon,pxe1610"; > + reg = <0x6c>; > + }; > + rdimm at 74 { > + compatible = "infineon,pxe1610"; > + reg = <0x74>; > + }; > + mdimm at 54 { > + compatible = "infineon,pxe1610"; > + reg = <0x5A>; > + }; > + ldimm at 44 { > + compatible = "infineon,pxe1610"; > + reg = <0x5C>; > + }; > + }; > + i2c5s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > +}; > + > +&i2c6 { > + /* SMB_TEMPSENSOR_STBY_LVC3_R */ > + multi-master; > + status = "okay"; > + > + i2c-switch at 70 { > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + #address-cells = <1>; > + #size-cells = <0>; > + > + i2c6s0ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + Please remove redundant blank lines > + > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch2: i2c at 2 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <2>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch3: i2c at 3 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <3>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + > + pca9548 at 71 { > + compatible = "nxp,pca9548"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + > + i2c6s1ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + }; > + i2c6s1ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + }; > + }; > + }; > + i2c6s0ch4: i2c at 4 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <4>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + > + pca9548 at 71 { > + compatible = "nxp,pca9548"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + > + i2c6s2ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + }; > + i2c6s2ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + }; > + }; > + }; > + i2c6s0ch5: i2c at 5 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <5>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + }; > +}; > + > +&i2c7 { > + status = "okay"; > + adc128d818 at 1d{ > + compatible = "ti,adc128d818"; > + reg = <0x1d>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 1e{ > + compatible = "ti,adc128d818"; > + reg = <0x1e>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 1f{ > + compatible = "ti,adc128d818"; > + reg = <0x1f>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2d{ > + compatible = "ti,adc128d818"; > + reg = <0x2d>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2e{ > + compatible = "ti,adc128d818"; > + reg = <0x2e>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2f{ > + compatible = "ti,adc128d818"; > + reg = <0x2f>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 35{ > + compatible = "ti,adc128d818"; > + reg = <0x35>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 36{ > + compatible = "ti,adc128d818"; > + reg = <0x36>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 37{ > + compatible = "ti,adc128d818"; > + reg = <0x37>; > + ti,mode = /bits/ 8 <0x01>; > + }; > +}; > + > +&i2c8 { > + status = "okay"; > + nct7362 at 20 { > + compatible = "nuvoton,nct7362"; > + device-active-gpios = <&gpio0 ASPEED_GPIO(N, 5) GPIO_ACTIVE_HIGH>; > + reg = <0x20>; > + }; There is no driver for nct7362 in openbmc/linux dev-6.6 (b97d6790d03b7) > + > + nct7362 at 22 { > + compatible = "nuvoton,nct7362"; > + device-active-gpios = <&gpio0 ASPEED_GPIO(N, 5) GPIO_ACTIVE_HIGH>; > + reg = <0x22>; > + }; as above > + > + pca9555 at 24{ > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + #address-cells = <1>; > + #size-cells = <0>; > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "FAN_PRSNT5_D_N", "FAN_PRSNT4_D_N", > + "FAN_PRSNT3_D_N", "FAN_PRSNT2_D_N", > + "FAN_PRSNT1_D_N", "FAN_PRSNT0_D_N", > + "", "", > + "", "", "", "", > + "", "", "", ""; > + }; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > + > +}; > + > +&i2c9 { > + status = "okay"; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > +}; > + > +&i2c10 { > + status = "okay"; > + pca9555 at 20 { > + compatible = "nxp,pca9555"; > + reg = <0x20>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "DIMM0_FAULT", "DIMM3_FAULT", > + "DIMM2_FAULT", "DIMM1_FAULT", > + "DIMM4_FAULT", "DIMM5_FAULT", > + "DIMM6_FAULT", "DIMM7_FAULT", > + "DIMM8_FAULT", "DIMM11_FAULT", > + "DIMM10_FAULT", "DIMM9_FAULT", > + "DIMM12_FAULT", "DIMM13_FAULT", > + "DIMM14_FAULT", "DIMM15_FAULT"; > + }; > + > + pca9555 at 22 { > + compatible = "nxp,pca9555"; > + reg = <0x22>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", "", "", "OCP0_PRSNT_N", "", "", "", > + "", "", "", "", "", "", "", ""; > + }; > + > + pca9555 at 23 { > + compatible = "nxp,pca9555"; > + reg = <0x23>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", "", "", "OCP1_PRSNT_N", "", "", "", > + "", "", "", "", "", "", "", ""; > + }; > +}; > + > +&i2c11 { > + status = "okay"; > + bus-timeout-ms = <100>; > + bus-recover-timeout-ms = <10>; bus-timeout-ms/bus-recover-timeout-ms don't exist in openbmc/linux dev-6.6(b97d6790d03b7) > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > +}; > + > +&i2c12 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c-mux-idle-disconnect; > + i2c12s0ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_0"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER0_BOARD_ID7", "RISER0_BOARD_ID6", > + "RISER0_BOARD_ID5", "RISER0_BOARD_ID4", > + "RISER0_BOARD_ID3", "RISER0_BOARD_ID2", > + "RISER0_BOARD_ID1", "RISER0_BOARD_ID0", > + "RISER0_SLOT2_PRSNT", "RISER0_SLOT1_PRSNT_X8", > + "RISER0_SLOT0_PRSNT_X8", "RISER0_SLOT1_PRSNT_X16", > + "RISER0_SLOT0_PRSNT_X16", "", "", ""; > + }; > + }; > + i2c12s0ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c12s0ch2: i2c at 2{ > + reg = <2>; > + }; > + i2c12s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > + > + pca9546 at 71{ > + compatible = "nxp,pca9546"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + i2c12s1ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_2"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER2_BOARD_ID0", "RISER2_BOARD_ID1", > + "RISER2_BOARD_ID2", "RISER2_BOARD_ID3", > + "RISER2_BOARD_ID4", "RISER2_BOARD_ID5", > + "RISER2_BOARD_ID6", "RISER2_BOARD_ID7", > + "RISER2_SLOT0_PRSNT", "RISER2_SLOT1_PRSNT", > + "", "", "", "", "", ""; > + }; > + }; > + i2c12s1ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c12s1ch2: i2c at 2{ > + reg = <2>; > + }; > + }; > +}; > + > +&i2c13 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c-mux-idle-disconnect; > + i2c13s0ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_1"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER1_BOARD_ID7", "RISER1_BOARD_ID6", > + "RISER1_BOARD_ID5", "RISER1_BOARD_ID4", > + "RISER1_BOARD_ID3", "RISER1_BOARD_ID2", > + "RISER1_BOARD_ID1", "RISER1_BOARD_ID0", > + "RISER1_SLOT2_PRSNT", "RISER1_SLOT1_PRSNT_X8", > + "RISER1_SLOT0_PRSNT_X8", "RISER1_SLOT1_PRSNT_X16", > + "RISER1_SLOT0_PRSNT_X16", "", "", ""; > + }; > + }; > + i2c13s0ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c13s0ch2: i2c at 2{ > + reg = <2>; > + }; > + i2c13s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > +}; > + > +&i2c14 { > + status = "okay"; > + idt1339 at 68{ > + compatible = "renesas,idt1339"; > + reg = <0x68>; > + }; > +}; "enesas,idt1339" doesn't exist in openbmc/linux dev-6.6 ((b97d6790d03b7) > + > +&i2c15 { > + status = "okay"; > +}; > + > +&ibt { > + status = "okay"; > +}; > + > +&uart1 { > + status = "okay"; > +}; > + > +&vuart1 { > + status = "okay"; > +}; > + > +&vuart2 { > + status = "okay"; > +}; > + > +&lpc_ctrl { > + status = "okay"; > + memory-region = <&flash_memory>; > +}; > + > +&wdt1 { > + status = "okay"; > + aspeed,reset-mask1 = <0x20f1ff1>; "reset-mask1" doesn't exist in opnebmc/linux dev-6.6(b97d6790d03b7) > +}; > + > +&kcs2 { > + status = "okay"; > + aspeed,lpc-io-reg = <0xca8 0xcac>; > +}; > + > +&kcs3 { > + status = "okay"; > + aspeed,lpc-io-reg = <0xca2>; > + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; > +}; > + > +&pcieh { > + status = "okay"; > +}; > + > +&mctp { > + status = "okay"; > +}; > + > +&bmc_dev { > + status = "okay"; > +}; > + > +&vhub { > + status = "okay"; > +}; > + > +&video { > + status = "okay"; > + memory-region = <&video_engine_memory>; > +}; > + > +&gfx { > + status = "okay"; > + memory-region = <&gfx_memory>; > +}; > -- > 2.34.1 > From rentao.bupt at gmail.com Thu Dec 14 17:20:16 2023 From: rentao.bupt at gmail.com (Tao Ren) Date: Wed, 13 Dec 2023 22:20:16 -0800 Subject: OpenBMC Linux 6.6 In-Reply-To: References: Message-ID: Hi Joel, Finally I got chance to sanity test Linux 6.6 on my AST2600 BMC, and everything looks good so far. I'm also planning to move all the Meta Network AST2400 and AST2500 BMC platforms to Linux 6.6, but I need to upgrade yocto at first (we are still running dunfell, which doesn't seem to be compatible with 6.6). Anyways, I will update back if I found problems. Again, thank you for maintaining the OpenBMC kernel tree! Cheers, Tao On Wed, Dec 06, 2023 at 05:29:59PM +1030, Joel Stanley wrote: > Hot on the heels of the last bump, here is the latest kernel base for > the aspeed machines. > > https://gerrit.openbmc.org/c/openbmc/openbmc/+/67772 > > If you're able to test, please comment on gerrit and give the change a +1. > > There was a config regression due to CONFIG_EMBEDDED going away, which > is fixed separately here: > > https://gerrit.openbmc.org/c/openbmc/openbmc/+/68117 > > Commit message for the bump follows: > > There are 56 patches in the tree, with 36 of those patches not > yet queued for merging in v6.7. > > v6.6 is an LTS kernel as decreed by the kernel.org maintainers. The > OpenBMC kernel maintainers encourage everyone to ship the latest kernel > as it has the most code review and upstream code. > > Andrew Jeffery (6): > dt-bindings: hwmon: pmbus: Add Maxim MAX31785 documentation > pmbus (max31785): Add support for devicetree configuration > pmbus (core): One-shot retries for failure to set page > pmbus (max31785): Wrap all I2C accessors in one-shot failure handlers > ARM: dts: aspeed: witherspoon: Update max31785 node > ipmi: kcs_bmc: Add a "raw" character device interface > > C?dric Le Goater (1): > /dev/mem: add a devmem kernel parameter to activate the device > > Eddie James (19): > dt-bindings: soc: Add Aspeed XDMA Engine > soc: aspeed: Add XDMA Engine Driver > soc: aspeed: xdma: Add user interface > soc: aspeed: xdma: Add reset ioctl > soc: aspeed: xdma: Add trace events > i2c: core: Add mux root adapter operations > iio: si7020: Lock root adapter to wait for reset > eeprom: ee1004: Enable devices on multiple busses > dt-bindings: trivial-devices: Add Atmel AT30TSE004A serial eeprom > eeprom: ee1004: Add OF matching support > leds: pca955x: Refactor with helper functions and renaming > leds: pca955x: Use pointers to driver data rather than I2C client > leds: pca955x: Optimize probe led selection > leds: pca955x: Add HW blink support > leds: Ensure hardware blinking turns off when requested > ARM: dts: aspeed: Rainier: Add fan controller properties > ARM: dts: aspeed: Everest: Add fan controller properties > ARM: dts: aspeed: Bonnell: Add fan controller properties > ARM: dts: aspeed: Rainier 4U: Delete fan dual-tach properties > > Jae Hyun Yoo (1): > clk: ast2600: enable BCLK for PCI/PCIe bus always > > Joel Stanley (7): > net: ftgmac100: Ensure tx descriptor updates are visible > ARM: aspeed: Add debugfs directory > ARM: soc: aspeed: Add secure boot controller support > dt-bindings: trivial-devices: Remove Infineon SLB9673 TPM > ARM: dts: nuvoton: npmc750-evb: Add default console > tpm: tis-i2c: Add more compatible strings > leds: pca955x: Revert "Remove the unused function pca95xx_num_led_regs()" > > Johannes Holland (1): > dt-bindings: tpm: Add schema for TIS I2C devices > > Potin Lai (1): > mtd: spi-nor: winbond: Add support for w25q01jvq > > Change-Id: I8b756421a7da84c0070e2ad4ac84a93984703457 > Signed-off-by: Joel Stanley From fancer.lancer at gmail.com Thu Dec 14 22:54:00 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 14 Dec 2023 14:54:00 +0300 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: <20231208163343.5s74bmirfna3o7yw@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> <20231205122316.ihhpklv222f5giz3@skbuf> <20231208163343.5s74bmirfna3o7yw@skbuf> Message-ID: Hi Vladimir, Sorry for the delayed response. Too much work at this time of the year (ah, Decembers)..( On Fri, Dec 08, 2023 at 06:33:43PM +0200, Vladimir Oltean wrote: > On Fri, Dec 08, 2023 at 05:11:20PM +0300, Serge Semin wrote: > > My idea was to reuse the mdio_device which has already been created > > either by means of the MDIO-bus OF-subnode or by means of the MDIO-bus > > board_info infrastructure (can be utilized in the SJA1105 or Wangxun > > Tx GBE). The xpcs_create() method then either probes the device on the MDIO > > bus and gets ID from there, or just uses the custom IDs based on the > > OF compatible match table or on the platform_data. If no MDIO-device > > was created my patchset is supposed to preserve the previous > > semantics: create MDIO-device, probe the device on the MDIO-bus, get > > device IDs from there. See the next patch for more details: > > https://lore.kernel.org/netdev/20231205103559.9605-11-fancer.lancer at gmail.com/ > > > > > That was attempted a while ago by > > > Sean Anderson with the Lynx PCS. Are you aware of the fact that even in > > > the good case in which binding the driver actually works, the user can > > > then come along and unbind it from the PCS device, and phylink isn't > > > prepared to handle that, so it will crash the kernel upon the next > > > phylink_pcs call? > > > > To be honest I didn't consider the driver bind/unbind option. But my > > case a bit different. DW XPCS MDIO-device is supposed to be created > > automatically by means of the DW XPCS MI driver from the DT-nodes > > hierarchy like this: > > mdio at 1f05d000 { > > compatible = "snps,dw-xpcs-mi"; > > reg = <0 0x1f05d000 0 0x1000>; > > > > xgmac_pcs: ethernet-pcs at 0 { > > compatible = "snps,dw-xpcs"; > > reg = <0>; > > }; > > }; > > The platform-device is created for the mdio at 1f05d000 node for which > > the DW XPCS MI driver is loaded, which calls the > > devm_of_mdiobus_register() in the probe() method which registers the > > MDIO-bus and then creates the MDIO-device from the ethernet-pcs at 0 > > node. The DW XPCS MDIO-device driver is attached to that MDIO-device > > then. In such model the PCS can be supplied to the DW *MAC via the > > "pcs-handle = &xgmac_pcs" property. > > > > Regarding the current semantics it's preserved in the framework of the > > xpcs_create_byaddr() method (former xpcs_create_mdiodev()) by means of > > the next code snippet: > > if (mdiobus_is_registered_device(bus, addr)) { > > mdiodev = bus->mdio_map[addr]; > > mdio_device_get(mdiodev); > > } else { > > mdiodev = mdio_device_create(bus, addr); > > if (IS_ERR(mdiodev)) > > return ERR_CAST(mdiodev); > > } > > Device can be automatically created if before registering the MDIO-bus > > the xpcs_create_byaddr() caller registered the MDIO-device board info > > by means of the mdiobus_register_board_info() method. In addition to > > that it's now possible to supply some custom data (custom device IDs > > in my implementation) to the XPCS driver by means of the > > mdio_board_info.platform_data field. See the next patch for > > reference: > > https://lore.kernel.org/netdev/20231205103559.9605-14-fancer.lancer at gmail.com > > > > So what the difference with the Lynx PCS is that in my case the > > MDIO-device is created automatically as a result of the DW XPCS MI > > MDIO-bus registration. Additionally I implemented the MDIO-device > > creation based on the MDIO-board-info, thus there won't be need in the > > calling mdio_device_create() on each xpcs_create_mdiodev() invocation. > > The later part isn't that important in the framework of this > > conversation, but just so you be aware. > > It's not really different, though. You can connect to the Lynx PCS both > ways, see dpaa2_pcs_create() which also searches for a pcs-handle before > calling lynx_pcs_create_fwnode(). Ah, right. Lynx PCS also implements the fwnode-based PCS descriptor creation. > What's subtly different is that we > don't (yet) have "fsl,lynx-pcs" compatible strings in the device tree. > So the MDIO controller will register the PCS devices as struct phy_device > (which still have an underlying struct mdio_device). The PCS layer > connects to the underlying struct mdio_device, and the phy_device on top > remains unconnected to any phylib/phylink MAC driver. That is confusing, > I should really get to adding those compatible strings to suppress the > phy_device creation. It hasn't been confirmed yet here https://lore.kernel.org/netdev/na6krkoco7pmsl62dfuj2xlrvpsnod74ptpfyy6gv7dzwmowga at mzsiknjian2i/ but AFAICS it is wrong to have a PCS device registered as PHY by any means: unmasking address in mii_bus->phy_mask or having the of_mdiobus_child_is_phy() returned true for a DT-node. So right, a specific compatible should be added to the PCS DT-nodes. > > > Regarding the driver bind/unbind. As I said I didn't actually consider > > that option. On the other hand my DW XPCS MDIO-device driver doesn't > > do actual probe() or remove(). The only implemented thing is the > > of_device_id table, which is used to assign PCS and PMA IDs if > > required based on the DT compatible property. So I can easily drop any > > MDIO device-driver part and parse the of_device_id table right in the > > xpcs_create_bynode(). From that perspective my implementation won't > > differ much from the Lynx PCS design. The only difference will be is > > the way the MDIO-bus is created and registered. In case of Lynx PCS > > the bus is created by the MAC-driver itself. > > Nope, not true. Follow the pcs-handle in arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi. Ah, right, I missed that case. I was referring to the cases when the Lynx PCS MDIO node is defined as a sub-node of the MAC node. > > > In my case DW XPCS MI is currently created in the framework of the > > separate platform driver. Do you think it would be better to follow > > the Lynx design pattern in order to get rid from the possibility of > > the DW XPCS MI driver being unbound behind the STMMAC+XPCS couple > > back? > > I think you actually pointed out a flaw in the Lynx PCS design too. > Actually, it is a larger flaw in the kernel. You can also unbind the > MDIO bus which holds the phy_device, and phylib (and therefore also > phylink) won't expect that either, so it will crash. > > > In this case the Dw MAC DT-node hierarchy would look like this: > > > > xgmac: ethernet at 1f054000 { > > compatible = "snps,dwxgmac"; > > reg = <0 0x1f054000 0 0x4000>; > > reg-names = "stmmaceth"; > > ranges; > > > > ... > > > > pcs-handle = &xgmac_pcs; > > > > // DW XPCS MI to access the DW XPCS attached to the device > > mdio at 1f05d000 { > > compatible = "snps,dwmac-mi"; > > reg = <0 0x1f05d000 0 0x1000>; > > > > xgmac_pcs: ethernet-pcs at 0 { > > compatible = "snps,dw-xpcs"; > > reg = <0>; > > }; > > }; > > > > // Normal MDIO-bus to access external PHYs (it's also called > > // as SMA - Station Management Agent - by Synopsys) > > mdio { > > compatible = "snps,dwmac-mdio"; > > #address-cells = <1>; > > #size-cells = <0>; > > }; > > }; > > > > I actually thought to use that hardware description pattern instead, > > but after some meditation around that I decided that having the DW > > XPCS device defined separately from the DW MAC node seemed better at > > least from the code separation point of view. Now I think that it > > wasn't the best decision. DW XPCS is always attached to the DW XGMAC > > controller. So it would be more correct having it defined as a > > sub-node. It would also helped to avoid the platform device driver > > bind/unbind problem. > > > > What do you think? Should I re-design my patchset to be supporting the > > design above? (After having conversion with you I am more inclined to > > do that now than to stick with the currently implemented solution.) > > I think that the placement of the "mdio" node as lateral vs subordinate > to the "ethernet" node would have fixed the issue by mistake. We should > be looking at it as a structural problem of the kernel instead. Don't > let it influence what you believe should be the correct design. Ok. Thanks for clarification. I won't move the PCS device DT-node to being subordinate of the MAC DT-node then. Although after some more digging into the problem I figured out that the solution still needs to be re-designed a bit. Currently I have the DW XPCS device represented as the nodes hierarchy: mdio at 1f05d000 { compatible = "snps,dwmac-mi"; reg = <0 0x1f05d000 0 0x1000>; xgmac_pcs: ethernet-pcs at 0 { compatible = "snps,dw-xpcs"; reg = <0>; }; }; When I introduced such representation I assumed that it was possible to have more than one DW XPCS devices accessible over the same MCI/APB interface with for instance some static offset. But it turned out I was wrong again. DW XPCS HW databook explicitly states that port_id_i[4:0] input signal is specific to the MDIO interface only. That signal is the MDIO-bus address of the device and it doesn't exist for the DW XPCS devices mapped to the system IO-memory via the MCI/APB buses. So there can't be more than one XPCS device accessible over the same MCI/APB port and the correct way to represent the DW XPCS device is just: xgmac_pcs: ethernet-pcs at 0 { compatible = "snps,dw-xpcs"; reg = <0 0x1f05d000 0 0x1000>; }; with no superior MI node. I'll re-design my patchset to support the device representation above then: just create a hidden MDIO-bus in the DW XPCS driver probe method and directly register the XPCS-device on it. The patch for the MDIO-bus subsystem will be gone after that. > > > > The pcs-rzn1-miic.c driver puts a device_link to the MAC to at least > > > tear down the whole thing when the PCS is unbound, which is saner than > > > crashing the kernel. I don't see the equivalent protection mechanism here? > > > > You are right. I don't have any equivalent protection here. Thanks for > > suggesting a solution. > > I think that a device link between the "ethernet" device and the "mdio" > device (controller, parent of the PHY or PCS), if the Ethernet is not a > parent of the MDIO controller, could also solve that. But it would also > require ACK from PHY maintainers, who may have grander plans to address > this snag. Ok. I'll add it in v2. Let's see what the maintainers think about that. Thanks for all your comments in my patchset regard. They are really helpful. -Serge(y) > > > > Can't the xpcs continue to live without a bound driver? Having a > > > compatible string in the OF description is perfectly fine though, > > > and should absolutely not preclude that. > > > > As I explained above Dw XPCS device can live without a bound driver > > because the DW XPCS MDIO-driver doesn't do much but merely gets to be > > bound based on the of_device_id table. In my case the problem is in > > the DW XPCS MI driver which indeed can be detached. Please see my > > long-read text above. > > Yeah, common design, common problem. From olteanv at gmail.com Thu Dec 14 23:00:16 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Thu, 14 Dec 2023 14:00:16 +0200 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> <20231205122316.ihhpklv222f5giz3@skbuf> <20231208163343.5s74bmirfna3o7yw@skbuf> Message-ID: <20231214120016.wgeip3mdro5ihnxe@skbuf> On Thu, Dec 14, 2023 at 02:54:00PM +0300, Serge Semin wrote: > > > > The pcs-rzn1-miic.c driver puts a device_link to the MAC to at least > > > > tear down the whole thing when the PCS is unbound, which is saner than > > > > crashing the kernel. I don't see the equivalent protection mechanism here? > > > > > > You are right. I don't have any equivalent protection here. Thanks for > > > suggesting a solution. > > > > I think that a device link between the "ethernet" device and the "mdio" > > device (controller, parent of the PHY or PCS), if the Ethernet is not a > > parent of the MDIO controller, could also solve that. But it would also > > require ACK from PHY maintainers, who may have grander plans to address > > this snag. > > Ok. I'll add it in v2. Let's see what the maintainers think about > that. Are you not following the parallel discussion on the topic of PCS devices having bound drivers? https://lore.kernel.org/netdev/ZXnV%2FPk1PYxAm%2FjS at shell.armlinux.org.uk/ Sadly I don't have much spare time to join that discussion, but it looks like you could. From fancer.lancer at gmail.com Thu Dec 14 23:28:57 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 14 Dec 2023 15:28:57 +0300 Subject: [PATCH net-next 10/16] net: pcs: xpcs: Add generic DW XPCS MDIO-device support In-Reply-To: <20231214120016.wgeip3mdro5ihnxe@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-11-fancer.lancer@gmail.com> <20231205111351.xjjuwpbf7kwg3vuh@skbuf> <20231205122316.ihhpklv222f5giz3@skbuf> <20231208163343.5s74bmirfna3o7yw@skbuf> <20231214120016.wgeip3mdro5ihnxe@skbuf> Message-ID: On Thu, Dec 14, 2023 at 02:00:16PM +0200, Vladimir Oltean wrote: > On Thu, Dec 14, 2023 at 02:54:00PM +0300, Serge Semin wrote: > > > > > The pcs-rzn1-miic.c driver puts a device_link to the MAC to at least > > > > > tear down the whole thing when the PCS is unbound, which is saner than > > > > > crashing the kernel. I don't see the equivalent protection mechanism here? > > > > > > > > You are right. I don't have any equivalent protection here. Thanks for > > > > suggesting a solution. > > > > > > I think that a device link between the "ethernet" device and the "mdio" > > > device (controller, parent of the PHY or PCS), if the Ethernet is not a > > > parent of the MDIO controller, could also solve that. But it would also > > > require ACK from PHY maintainers, who may have grander plans to address > > > this snag. > > > > Ok. I'll add it in v2. Let's see what the maintainers think about > > that. > > Are you not following the parallel discussion on the topic of PCS > devices having bound drivers? > https://lore.kernel.org/netdev/ZXnV%2FPk1PYxAm%2FjS at shell.armlinux.org.uk/ > > Sadly I don't have much spare time to join that discussion, but it looks > like you could. Ok. Thanks for sharing the link. At least I'll follow up the discussion in order to pick up/wait for a solution they'll come up with. -Serge(y) From arnd at arndb.de Thu Dec 14 23:44:24 2023 From: arnd at arndb.de (Arnd Bergmann) Date: Thu, 14 Dec 2023 13:44:24 +0100 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <20231213190528.3751583-4-tmaimon77@gmail.com> References: <20231213190528.3751583-1-tmaimon77@gmail.com> <20231213190528.3751583-4-tmaimon77@gmail.com> Message-ID: On Wed, Dec 13, 2023, at 20:05, Tomer Maimon wrote: > Add Nuvoton BMC NPCM BIOS post code (BPC) driver. > > The NPCM BPC monitoring two configurable I/O address written by the host > on the bus. > > Signed-off-by: Tomer Maimon > --- > drivers/soc/nuvoton/Kconfig | 9 + > drivers/soc/nuvoton/Makefile | 1 + > drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++ > 3 files changed, 397 insertions(+) > create mode 100644 drivers/soc/nuvoton/npcm-bpc.c I try hard to avoid having user interfaces in drivers/soc/, that subsystem should primarily be used for things that don't have an existing subsystem in the kernel and are used by other in-kernel drivers but don't export hteir own misc device. > diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig > index d5102f5f0c28..ebd162633942 100644 > --- a/drivers/soc/nuvoton/Kconfig > +++ b/drivers/soc/nuvoton/Kconfig > @@ -2,6 +2,15 @@ > > menu "NUVOTON SoC drivers" > > +config NPCM_BPC > + tristate "NPCM BIOS Post Code support" > + depends on (ARCH_NPCM || COMPILE_TEST) > + help > + Provides NPCM driver to control the BIOS Post Code > + interface which allows the BMC to monitor and save > + the data written by the host to an arbitrary I/O port, > + the BPC is connected to the host thourgh LPC or eSPI bus. > + This one in particular looks like this might be implemented by more than one BMC type, it's a fairly generic functionality. Have you talked to the other maintainers of SoCs used in OpenBMC about coming up with a common interface? > +#define DEVICE_NAME "npcm-bpc" [nitpicking] No need for macros like this one, open-coding the string is usually more readable. Arnd From tmaimon77 at gmail.com Fri Dec 15 00:34:53 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 14 Dec 2023 15:34:53 +0200 Subject: [PATCH v3 1/3] dt-bindings: soc: nuvoton: Add NPCM BPC In-Reply-To: References: <20231213190528.3751583-1-tmaimon77@gmail.com> <20231213190528.3751583-2-tmaimon77@gmail.com> Message-ID: Hi Krzysztof, Thanks for your comments. On Thu, 14 Dec 2023 at 09:56, Krzysztof Kozlowski wrote: > > On 13/12/2023 20:05, Tomer Maimon wrote: > > Added device tree binding documentation for Nuvoton BMC NPCM BIOS Post > > Code (BPC). > > > > The NPCM BPC monitoring two configurable I/O addresses written by the > > host on the bus. > > > > Signed-off-by: Tomer Maimon > > --- > > .../soc/nuvoton/nuvoton,npcm-bpc.yaml | 65 +++++++++++++++++++ > > 1 file changed, 65 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml > > > > diff --git a/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml > > new file mode 100644 > > index 000000000000..c04302a1d52b > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/soc/nuvoton/nuvoton,npcm-bpc.yaml > > @@ -0,0 +1,65 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/soc/nuvoton/nuvoton,npcm-bpc.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Nuvoton BMC NPCM BIOS Post Code (BPC) controller > > + > > +maintainers: > > + - Tomer Maimon > > + > > +description: > > + Nuvoton BMC NPCM BIOS Post Code (BPC) monitoring two configurable I/O > > + addresses written by the host on the bus, the capture data stored in > > + 128-word FIFO. > > + > > + NPCM BPC supports capture double words, when using capture > > + double word only I/O address 1 is monitored. > > + > > +properties: > > + compatible: > > + items: > > + - enum: > > + - nuvoton,npcm845-bpc > > + - nuvoton,npcm750-bpc > > + - const: nuvoton,npcm-bpc > > That's not what I suggested. I asked to make 845 compatible with 750. > This works, but I want to be sure you really, really understand the > consequences of this. Did you mean to do the compatible as follows? properties: compatible: items: - enum: - nuvoton,npcm845-bpc - const: nuvoton,npcm750-bpc Appreciate it if you could explain what is the difference between the compatibility suggested in V3? > > > + > > + reg: > > + maxItems: 1 > > + > > + interrupts: > > + maxItems: 1 > > + > > + nuvoton,monitor-ports: > > + $ref: /schemas/types.yaml#/definitions/uint32-array > > Missing constraints, like min/maxItems and maybe values. O.K. > > > + description: > > + Contain monitor I/O addresses on the bus, at least one monitor I/O > > + address required. > > + > > + nuvoton,bpc-en-dwcapture: > > nuvoton,double-word-capture? Modify in V4 > > > + description: > > + Set DWCAPTURE bit in BPCFEN register that enables double word capture > > + according to the first address setting. > > + type: boolean > > + > > +required: > > + - compatible > > + - reg > > + - interrupts > > + - nuvoton,monitor-ports > > Best regards, > Krzysztof > Thanks, Tomer From tmaimon77 at gmail.com Fri Dec 15 01:09:29 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 14 Dec 2023 16:09:29 +0200 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: References: <20231213190528.3751583-1-tmaimon77@gmail.com> <20231213190528.3751583-4-tmaimon77@gmail.com> Message-ID: Hi Arnd, Thanks for your comments. On Thu, 14 Dec 2023 at 14:44, Arnd Bergmann wrote: > > On Wed, Dec 13, 2023, at 20:05, Tomer Maimon wrote: > > Add Nuvoton BMC NPCM BIOS post code (BPC) driver. > > > > The NPCM BPC monitoring two configurable I/O address written by the host > > on the bus. > > > > Signed-off-by: Tomer Maimon > > --- > > drivers/soc/nuvoton/Kconfig | 9 + > > drivers/soc/nuvoton/Makefile | 1 + > > drivers/soc/nuvoton/npcm-bpc.c | 387 +++++++++++++++++++++++++++++++++ > > 3 files changed, 397 insertions(+) > > create mode 100644 drivers/soc/nuvoton/npcm-bpc.c > > I try hard to avoid having user interfaces in drivers/soc/, that > subsystem should primarily be used for things that don't have an > existing subsystem in the kernel and are used by other in-kernel > drivers but don't export hteir own misc device. > > > diff --git a/drivers/soc/nuvoton/Kconfig b/drivers/soc/nuvoton/Kconfig > > index d5102f5f0c28..ebd162633942 100644 > > --- a/drivers/soc/nuvoton/Kconfig > > +++ b/drivers/soc/nuvoton/Kconfig > > @@ -2,6 +2,15 @@ > > > > menu "NUVOTON SoC drivers" > > > > +config NPCM_BPC > > + tristate "NPCM BIOS Post Code support" > > + depends on (ARCH_NPCM || COMPILE_TEST) > > + help > > + Provides NPCM driver to control the BIOS Post Code > > + interface which allows the BMC to monitor and save > > + the data written by the host to an arbitrary I/O port, > > + the BPC is connected to the host thourgh LPC or eSPI bus. > > + > > This one in particular looks like this might be implemented > by more than one BMC type, it's a fairly generic functionality. > > Have you talked to the other maintainers of SoCs used in > OpenBMC about coming up with a common interface? Yes, Both Nuvoton and Aspeed use the same user-facing code to manage the host snooping. https://github.com/openbmc/phosphor-host-postd > > > +#define DEVICE_NAME "npcm-bpc" Will do. > > [nitpicking] No need for macros like this one, open-coding the > string is usually more readable. > > Arnd Thanks, Tomer From fancer.lancer at gmail.com Fri Dec 15 01:19:04 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Thu, 14 Dec 2023 17:19:04 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> Message-ID: On Wed, Dec 13, 2023 at 04:32:21PM +0000, Russell King (Oracle) wrote: > On Wed, Dec 13, 2023 at 03:01:45AM +0300, Serge Semin wrote: > > On Tue, Dec 05, 2023 at 01:46:44PM +0000, Russell King (Oracle) wrote: > > > xpcs_create_mdiodev() as it originally stood creates the mdiodev from > > > the bus/address, and then passes that to xpcs_create(). Once > > > xpcs_create() has finished its work (irrespective of whether it was > > > successful or not) we're done with the mdiodev in this function, so > > > the reference is _always_ put. > > > > You say that it's required to manage the refcounting twice: when we > > get the reference from some external place and internally when the > > reference is stored in the XPCS descriptor. What's the point in such > > redundancy with the internal ref-counting if we know that the pointer > > can be safely stored and utilized afterwards? Better maintainability? > > Is it due to having the object retrieval and storing implemented in > > different functions? > > The point is that the error handling gets simpler: > - One can see in xpcs_create_mdiodev() that the reference taken by > mdio_device_create() is always dropped if that function was > successful, irrespective of whether xpcs_create() was successful. > > - xpcs_create() is responsible for managing the refcount on the mdiodev > that is passed to it - and if it's successful, it needs to increment > the refcount, or leave it in the same state as it was on entry if > failing. > > This avoids complexities in error paths, which are notorious for things > being forgotten - since with this, each of these functions is resposible > for managing its refcount. > > It's a different style of refcount management, one I think more people > should adopt. > > > While at it if you happen to know an answer could you please also > > clarify the next question. None of the ordinary > > platform/PCI/USB/hwmon/etc drivers I've been working with managed > > refcounting on storing a passed to probe() device pointer in the > > private driver data. Is it wrong not doing that? > > If we wanted to do refcounting strictly, then every time a new > pointer to a data structure is created, we should be taking a refcount > on it, and each time that pointer is destroyed, we should be putting > the refcount. That is what refcounting is all about. > > However, there are circumstances where this can be done lazily, and > for drivers we would prefer driver authors not to end up with > refcount errors where they've forgotten to put something. > > In the specific case of drivers, we have a well defined lifetime for > a device bound to a driver. We guarantee that the struct device will > not go away if a driver is bound to the device, until such time that > the driver's .remove method has been called. Thus, we guarantee that > the device driver will be notified of the struct device going away > before it has been freed. This frees the driver author from having > to worry about the refcount of the struct device. > > As soon as we start doing stuff that is outside of that model, then > objects that are refcounted need to be dealt with, and I much prefer > the "strict" refcounting implementation such as the one I added to > xpcs, because IMHO it's much easier to see that the flow is obviously > correct - even if it does need a comment to describe why we always > do a put. Ok. I fully get your point now: lazy refcounting for the drivers following standard model and the 'strict' one for others. It sounds reasonable. I'll get that adopted in my future developments. Thank you very much for the detailed explanation and for all your comments. -Serge(y) > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last! From geissonator at gmail.com Fri Dec 15 01:51:06 2023 From: geissonator at gmail.com (Andrew Geissler) Date: Thu, 14 Dec 2023 08:51:06 -0600 Subject: Gerrit Upgrade December 15, 2023 Message-ID: It's that time of the year again. Lets shoot for a gerrit upgrade tomorrow morning (US Central time). I'll take it down around 8:00am and if all goes well it shouldn't be down for more then an hour. Andrew From arnd at arndb.de Fri Dec 15 02:48:55 2023 From: arnd at arndb.de (Arnd Bergmann) Date: Thu, 14 Dec 2023 15:48:55 +0000 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: References: <20231213190528.3751583-1-tmaimon77@gmail.com> <20231213190528.3751583-4-tmaimon77@gmail.com> Message-ID: <88040035-d971-4012-bb9f-9f2ae91fdc6e@app.fastmail.com> On Thu, Dec 14, 2023, at 14:09, Tomer Maimon wrote: > On Thu, 14 Dec 2023 at 14:44, Arnd Bergmann wrote: >> > >> > +config NPCM_BPC >> > + tristate "NPCM BIOS Post Code support" >> > + depends on (ARCH_NPCM || COMPILE_TEST) >> > + help >> > + Provides NPCM driver to control the BIOS Post Code >> > + interface which allows the BMC to monitor and save >> > + the data written by the host to an arbitrary I/O port, >> > + the BPC is connected to the host thourgh LPC or eSPI bus. >> > + >> >> This one in particular looks like this might be implemented >> by more than one BMC type, it's a fairly generic functionality. >> >> Have you talked to the other maintainers of SoCs used in >> OpenBMC about coming up with a common interface? > Yes, Both Nuvoton and Aspeed use the same user-facing code to manage > the host snooping. > https://github.com/openbmc/phosphor-host-postd Ok, that's good. I found the driver in drivers/soc/aspeed/aspeed-lpc-snoop.c now and see that the implementation looks very similar. I think we should do two things here: - split out the common code into a shared module that exports the symbols to be used by either one - find a better place for both drivers outside of drivers/soc. I would suggest drivers/misc/bmc/ but am open to other suggestions. Arnd From tmaimon77 at gmail.com Fri Dec 15 03:50:21 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 14 Dec 2023 18:50:21 +0200 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <88040035-d971-4012-bb9f-9f2ae91fdc6e@app.fastmail.com> References: <20231213190528.3751583-1-tmaimon77@gmail.com> <20231213190528.3751583-4-tmaimon77@gmail.com> <88040035-d971-4012-bb9f-9f2ae91fdc6e@app.fastmail.com> Message-ID: Hi Arnd, Thanks for your suggestion. Appreciate it if Joel, OpenBMC Linux kernel maintainer, could share his thoughts about it. On Thu, 14 Dec 2023 at 17:49, Arnd Bergmann wrote: > > On Thu, Dec 14, 2023, at 14:09, Tomer Maimon wrote: > > On Thu, 14 Dec 2023 at 14:44, Arnd Bergmann wrote: > >> > > >> > +config NPCM_BP > >> > + tristate "NPCM BIOS Post Code support" > >> > + depends on (ARCH_NPCM || COMPILE_TEST) > >> > + help > >> > + Provides NPCM driver to control the BIOS Post Code > >> > + interface which allows the BMC to monitor and save > >> > + the data written by the host to an arbitrary I/O port, > >> > + the BPC is connected to the host thourgh LPC or eSPI bus. > >> > + > >> > >> This one in particular looks like this might be implemented > >> by more than one BMC type, it's a fairly generic functionality. > >> > >> Have you talked to the other maintainers of SoCs used in > >> OpenBMC about coming up with a common interface? > > Yes, Both Nuvoton and Aspeed use the same user-facing code to manage > > the host snooping. > > https://github.com/openbmc/phosphor-host-postd > > Ok, that's good. I found the driver in drivers/soc/aspeed/aspeed-lpc-snoop.c > now and see that the implementation looks very similar. > > I think we should do two things here: > > - split out the common code into a shared module that exports the > symbols to be used by either one > > - find a better place for both drivers outside of drivers/soc. > I would suggest drivers/misc/bmc/ but am open to other suggestions. > > Arnd Best regards, Tomer From robh at kernel.org Fri Dec 15 04:40:58 2023 From: robh at kernel.org (Rob Herring) Date: Thu, 14 Dec 2023 11:40:58 -0600 Subject: [PATCH net-next 08/16] dt-bindings: net: Add Synopsys DW xPCS bindings In-Reply-To: <20231205103559.9605-9-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-9-fancer.lancer@gmail.com> Message-ID: <20231214174058.GA624576-robh@kernel.org> On Tue, Dec 05, 2023 at 01:35:29PM +0300, Serge Semin wrote: > Synopsys DesignWare XPCS IP-core is a Physical Coding Sublayer (PCS) layer > providing an interface between the Media Access Control (MAC) and Physical > Medium Attachment Sublayer (PMA) through a Media independent interface. > >From software point of view it exposes IEEE std. Clause 45 CSR space and > can be accessible either by MDIO or MCI/APB3 bus interfaces. The later > case is described by means of a dedicated DT-bindings which imply having > the DW XPCS Management Interface defined as a DT-supernode which child the > PCSs nodes would be (in the same way as the standard MDIO buses and > devices are normally defined). > > Besides of that DW XPCS DT-nodes can have the interrupts and clock source > properties specified. The former one indicates the Clause 73/37 > auto-negotiation events like: negotiation page received, AN is completed > or incompatible link partner. The clock DT-properties can describe up to > two clock sources: internal one and the one connected to the chip pad. > Either of them is supposed to be used as the device reference clocks. > > Finally the DW XPCS IP-core can be optionally synthesized with a > vendor-specific interface connected to Synopsys PMA (also called > DesignWare Consumer/Enterprise PHY). Alas that isn't auto-detectable > anyhow so if the DW XPCS device has the respective PMA attached then it > should be reflected in the DT-node compatible string so the driver would > be aware of the PMA-specific device capabilities (mainly connected with > CSRs available for the fine-tunings). > > Signed-off-by: Serge Semin > --- > .../bindings/net/pcs/snps,dw-xpcs.yaml | 88 +++++++++++++++++++ > .../bindings/net/snps,dw-xpcs-mi.yaml | 88 +++++++++++++++++++ > 2 files changed, 176 insertions(+) > create mode 100644 Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml > create mode 100644 Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml > > diff --git a/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml > new file mode 100644 > index 000000000000..9694ef51abad > --- /dev/null > +++ b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml > @@ -0,0 +1,88 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/net/pcs/snps,dw-xpcs.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Synopsys DesignWare Ethernet PCS > + > +maintainers: > + - Jose Abreu > + > +description: > + Synopsys DesignWare Ethernet Physical Coding Sublayer provides an interface > + between Media Access Control and Physical Medium Attachment Sublayer through > + the Media Independent Interface (XGMII, USXGMII, XLGMII, GMII, etc) > + controlled by means of the IEEE std. Clause 45 registers set. The PCS can be > + optionally synthesized with a vendor-specific interface connected to > + Synopsys PMA (also called DesignWare Consumer/Enterprise PHY) although in > + general it can be used to communicate with any compatible PHY. > + > +properties: > + compatible: > + oneOf: > + - description: Synopsys DesignWare XPCS with none or unknown PMA > + const: snps,dw-xpcs > + - description: Synopsys DesignWare XPCS with Consumer Gen1 3G PMA > + const: snps,dw-xpcs-gen1-3g > + - description: Synopsys DesignWare XPCS with Consumer Gen2 3G PMA > + const: snps,dw-xpcs-gen2-3g > + - description: Synopsys DesignWare XPCS with Consumer Gen2 6G PMA > + const: snps,dw-xpcs-gen2-6g > + - description: Synopsys DesignWare XPCS with Consumer Gen4 3G PMA > + const: snps,dw-xpcs-gen4-3g > + - description: Synopsys DesignWare XPCS with Consumer Gen4 6G PMA > + const: snps,dw-xpcs-gen4-6g > + - description: Synopsys DesignWare XPCS with Consumer Gen5 10G PMA > + const: snps,dw-xpcs-gen5-10g > + - description: Synopsys DesignWare XPCS with Consumer Gen5 12G PMA > + const: snps,dw-xpcs-gen5-12g > + > + reg: > + maxItems: 1 > + > + interrupts: > + description: > + System interface interrupt output (sbd_intr_o) indicating Clause 73/37 > + auto-negotiation events like':' Page received, AN is completed or like':' ? > + incompatible link partner. > + maxItems: 1 > + > + clocks: > + description: > + PCS/PMA interface be can clocked either by internal reference clock > + source or by an externally connected (via a pad) clock generator. > + minItems: 1 > + maxItems: 2 > + > + clock-names: > + minItems: 1 > + maxItems: 2 > + items: > + enum: [ core, pad ] > + > +required: > + - compatible > + - reg Don't you always need a clock? > + > +additionalProperties: false > + > +examples: > + - | > + #include > + > + mdio-bus { > + #address-cells = <1>; > + #size-cells = <0>; > + > + xgmac_pcs: ethernet-pcs at 0 { > + compatible = "snps,dw-xpcs"; > + reg = <0>; > + > + interrupts = <79 IRQ_TYPE_LEVEL_HIGH>; > + > + clocks = <&ccu_core>, <&ccu_pad>; > + clock-names = "core", "pad"; > + }; > + }; > +... > diff --git a/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml > new file mode 100644 > index 000000000000..67ddba9d61fd > --- /dev/null > +++ b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml > @@ -0,0 +1,88 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/net/snps,dw-xpcs-mi.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: Synopsys DesignWare Ethernet PCS Management Interface > + > +maintainers: > + - Serge Semin > + > +description: > + Synopsys DesignWare Ethernet PCS provides an interface between MAC and PMA > + through the Media Independent Interface. The PCS CSRs can be accessible over > + the Ethernet MDIO bus or directly by means of the APB3/MCI interfaces. In the > + later case the XPCS can be mapped right to the system IO memory space. > + > +allOf: > + - $ref: mdio.yaml# > + > +properties: > + compatible: > + const: snps,dw-xpcs-mi > + > + reg: > + items: > + - description: > + DW XPCS CSRs space can be either 'directly' or 'indirectly' > + accessible. In the former case all Clause 45 registers are > + contiguously mapped within the address space MMD '[20:16]', > + Reg '[15:0]'. In the later case the space is divided to the > + multiple 256 register sets. There is a special viewport CSR > + which is responsible for the set selection. The upper part of > + the CSR address is supposed to be written in there thus the > + corresponding subset would be mapped over the lowest 255 CSRs. > + > + reg-names: > + items: > + - enum: [ direct, indirect ] > + > + reg-io-width: > + description: > + The way the CSRs are mapped to the memory is platform depended. Since dependent > + each Clause 45 CSR is of 16-bits wide the access instructions must be > + two bytes aligned at least. > + default: 2 > + enum: [ 2, 4 ] > + > + clocks: > + items: > + - description: Peripheral MCI/APB3 bus clock source > + > + clock-names: > + items: > + - const: pclk > + > +patternProperties: > + 'ethernet-pcs@[0-9a-f]+$': > + type: object > + > + $ref: pcs/snps,dw-xpcs.yaml# This causes dw-xpcs to be validated twice. Does this MDIO bus support other devices on it or it is fixed config? > + > +required: > + - compatible > + - reg > + - reg-names > + > +unevaluatedProperties: false > + > +examples: > + - | > + mdio at 1f05d000 { > + compatible = "snps,dw-xpcs-mi"; > + reg = <0x1f05d000 0x1000>; > + reg-names = "indirect"; > + #address-cells = <1>; > + #size-cells = <0>; > + > + clocks = <&ccu_pclk>; > + clock-names = "pclk"; > + > + reg-io-width = <4>; > + > + ethernet-pcs at 0 { > + compatible = "snps,dw-xpcs"; > + reg = <0>; > + }; > + }; > -- > 2.42.1 > From fancer.lancer at gmail.com Fri Dec 15 08:27:31 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Fri, 15 Dec 2023 00:27:31 +0300 Subject: [PATCH net-next 08/16] dt-bindings: net: Add Synopsys DW xPCS bindings In-Reply-To: <20231214174058.GA624576-robh@kernel.org> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-9-fancer.lancer@gmail.com> <20231214174058.GA624576-robh@kernel.org> Message-ID: <52rttyyba6tbklxqv3gif2oyz4ttwlqcaljdkjesb6vaji45pz@46u6t573y7k2> Hi Rob On Thu, Dec 14, 2023 at 11:40:58AM -0600, Rob Herring wrote: > On Tue, Dec 05, 2023 at 01:35:29PM +0300, Serge Semin wrote: > > Synopsys DesignWare XPCS IP-core is a Physical Coding Sublayer (PCS) layer > > providing an interface between the Media Access Control (MAC) and Physical > > Medium Attachment Sublayer (PMA) through a Media independent interface. > > >From software point of view it exposes IEEE std. Clause 45 CSR space and > > can be accessible either by MDIO or MCI/APB3 bus interfaces. The later > > case is described by means of a dedicated DT-bindings which imply having > > the DW XPCS Management Interface defined as a DT-supernode which child the > > PCSs nodes would be (in the same way as the standard MDIO buses and > > devices are normally defined). > > > > Besides of that DW XPCS DT-nodes can have the interrupts and clock source > > properties specified. The former one indicates the Clause 73/37 > > auto-negotiation events like: negotiation page received, AN is completed > > or incompatible link partner. The clock DT-properties can describe up to > > two clock sources: internal one and the one connected to the chip pad. > > Either of them is supposed to be used as the device reference clocks. > > > > Finally the DW XPCS IP-core can be optionally synthesized with a > > vendor-specific interface connected to Synopsys PMA (also called > > DesignWare Consumer/Enterprise PHY). Alas that isn't auto-detectable > > anyhow so if the DW XPCS device has the respective PMA attached then it > > should be reflected in the DT-node compatible string so the driver would > > be aware of the PMA-specific device capabilities (mainly connected with > > CSRs available for the fine-tunings). > > > > Signed-off-by: Serge Semin > > --- > > .../bindings/net/pcs/snps,dw-xpcs.yaml | 88 +++++++++++++++++++ > > .../bindings/net/snps,dw-xpcs-mi.yaml | 88 +++++++++++++++++++ > > 2 files changed, 176 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml > > create mode 100644 Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml > > > > diff --git a/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml > > new file mode 100644 > > index 000000000000..9694ef51abad > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/net/pcs/snps,dw-xpcs.yaml > > @@ -0,0 +1,88 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/net/pcs/snps,dw-xpcs.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Synopsys DesignWare Ethernet PCS > > + > > +maintainers: > > + - Jose Abreu > > + > > +description: > > + Synopsys DesignWare Ethernet Physical Coding Sublayer provides an interface > > + between Media Access Control and Physical Medium Attachment Sublayer through > > + the Media Independent Interface (XGMII, USXGMII, XLGMII, GMII, etc) > > + controlled by means of the IEEE std. Clause 45 registers set. The PCS can be > > + optionally synthesized with a vendor-specific interface connected to > > + Synopsys PMA (also called DesignWare Consumer/Enterprise PHY) although in > > + general it can be used to communicate with any compatible PHY. > > + > > +properties: > > + compatible: > > + oneOf: > > + - description: Synopsys DesignWare XPCS with none or unknown PMA > > + const: snps,dw-xpcs > > + - description: Synopsys DesignWare XPCS with Consumer Gen1 3G PMA > > + const: snps,dw-xpcs-gen1-3g > > + - description: Synopsys DesignWare XPCS with Consumer Gen2 3G PMA > > + const: snps,dw-xpcs-gen2-3g > > + - description: Synopsys DesignWare XPCS with Consumer Gen2 6G PMA > > + const: snps,dw-xpcs-gen2-6g > > + - description: Synopsys DesignWare XPCS with Consumer Gen4 3G PMA > > + const: snps,dw-xpcs-gen4-3g > > + - description: Synopsys DesignWare XPCS with Consumer Gen4 6G PMA > > + const: snps,dw-xpcs-gen4-6g > > + - description: Synopsys DesignWare XPCS with Consumer Gen5 10G PMA > > + const: snps,dw-xpcs-gen5-10g > > + - description: Synopsys DesignWare XPCS with Consumer Gen5 12G PMA > > + const: snps,dw-xpcs-gen5-12g > > + > > + reg: > > + maxItems: 1 > > + > > + interrupts: > > + description: > > + System interface interrupt output (sbd_intr_o) indicating Clause 73/37 > > + auto-negotiation events like':' Page received, AN is completed or > > like':' ? Right. I'll drop it. > > > + incompatible link partner. > > + maxItems: 1 > > + > > + clocks: > > + description: > > + PCS/PMA interface be can clocked either by internal reference clock s/be can/can be > > + source or by an externally connected (via a pad) clock generator. > > + minItems: 1 > > + maxItems: 2 > > + > > + clock-names: > > + minItems: 1 > > + maxItems: 2 > > + items: > > + enum: [ core, pad ] > > + > > +required: > > + - compatible > > + - reg > > Don't you always need a clock? It depends on the PMA nature. Synopsys PHY requires either of the two clocks: alt/core clock or pad clock. Both of them might be supplied on a platform though, but only one can be selected at a time. It's done by means of the Synopsys PHY-specific CSR exposed in the MMD 1 (PMA/PMD). If there is non-Synopsys PHY (PMA) attached then I guess it can be also clocked somehow, but it will be platform-depended. > > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > + #include > > + > > + mdio-bus { > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + xgmac_pcs: ethernet-pcs at 0 { > > + compatible = "snps,dw-xpcs"; > > + reg = <0>; > > + > > + interrupts = <79 IRQ_TYPE_LEVEL_HIGH>; > > + > > + clocks = <&ccu_core>, <&ccu_pad>; > > + clock-names = "core", "pad"; > > + }; > > + }; > > +... > > diff --git a/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml > > new file mode 100644 > > index 000000000000..67ddba9d61fd > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/net/snps,dw-xpcs-mi.yaml > > @@ -0,0 +1,88 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/net/snps,dw-xpcs-mi.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: Synopsys DesignWare Ethernet PCS Management Interface > > + > > +maintainers: > > + - Serge Semin > > + > > +description: > > + Synopsys DesignWare Ethernet PCS provides an interface between MAC and PMA > > + through the Media Independent Interface. The PCS CSRs can be accessible over > > + the Ethernet MDIO bus or directly by means of the APB3/MCI interfaces. In the > > + later case the XPCS can be mapped right to the system IO memory space. > > + > > +allOf: > > + - $ref: mdio.yaml# > > + > > +properties: > > + compatible: > > + const: snps,dw-xpcs-mi > > + > > + reg: > > + items: > > + - description: > > + DW XPCS CSRs space can be either 'directly' or 'indirectly' > > + accessible. In the former case all Clause 45 registers are > > + contiguously mapped within the address space MMD '[20:16]', > > + Reg '[15:0]'. In the later case the space is divided to the > > + multiple 256 register sets. There is a special viewport CSR > > + which is responsible for the set selection. The upper part of > > + the CSR address is supposed to be written in there thus the > > + corresponding subset would be mapped over the lowest 255 CSRs. > > + > > + reg-names: > > + items: > > + - enum: [ direct, indirect ] > > + > > + reg-io-width: > > + description: > > + The way the CSRs are mapped to the memory is platform depended. Since > > dependent Ok. > > > + each Clause 45 CSR is of 16-bits wide the access instructions must be > > + two bytes aligned at least. > > + default: 2 > > + enum: [ 2, 4 ] > > + > > + clocks: > > + items: > > + - description: Peripheral MCI/APB3 bus clock source > > + > > + clock-names: > > + items: > > + - const: pclk > > + > > +patternProperties: > > + 'ethernet-pcs@[0-9a-f]+$': > > + type: object > > + > > + $ref: pcs/snps,dw-xpcs.yaml# > > This causes dw-xpcs to be validated twice. Does this MDIO bus support > other devices on it or it is fixed config? It turned out I was wrong to define the DW XPCS interface as the MDIO bus. DW XPCS can be synthesized with one of the next management interfaces: 1. MDIO - normal serial MDIO-bus interface. 2-3. MCI/APB3 - parallel interfaces so the PCS device can be easier embedded into the system memory bus. Initially I thought that more than one device can be accessible over the same MCI/APB3 port with the MS bits being used to reach particular device. But just recently I discovered that it wasn't correct. The port_id_i[4:0] input signal isn't present for the MCI or APB3 interface. Thus the DW XPCS device is just a normal memory-mapped platform device with no such thing like DW XPCS MI above. I'll change the currently implemented hierarchical device representation from: mdio at 1f05d000 { compatible = "snps,dwmac-mi"; reg = <0 0x1f05d000 0 0x1000>; xgmac_pcs: ethernet-pcs at 0 { compatible = "snps,dw-xpcs"; reg = <0>; }; }; to just a single node: xgmac_pcs: ethernet-pcs at 0 { compatible = "snps,dw-xpcs"; reg = <0 0x1f05d000 0 0x1000>; ... }; I pointed that out earlier today in a comment to another patch of this series: https://lore.kernel.org/netdev/xhj7jchcv63y2bmnedxqffnmh3fvdxirccdugnnljruemuiurz at ceafs7mivbqp/ -Serge(y) > > > + > > +required: > > + - compatible > > + - reg > > + - reg-names > > + > > +unevaluatedProperties: false > > + > > +examples: > > + - | > > + mdio at 1f05d000 { > > + compatible = "snps,dw-xpcs-mi"; > > + reg = <0x1f05d000 0x1000>; > > + reg-names = "indirect"; > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + clocks = <&ccu_pclk>; > > + clock-names = "pclk"; > > + > > + reg-io-width = <4>; > > + > > + ethernet-pcs at 0 { > > + compatible = "snps,dw-xpcs"; > > + reg = <0>; > > + }; > > + }; > > -- > > 2.42.1 > > From andrew at codeconstruct.com.au Fri Dec 15 09:21:03 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Fri, 15 Dec 2023 08:51:03 +1030 Subject: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <2eab42cde34723a195e7a0287db08b25f8388a3b.camel@codeconstruct.com.au> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-3-quan@os.amperecomputing.com> <2eab42cde34723a195e7a0287db08b25f8388a3b.camel@codeconstruct.com.au> Message-ID: <54cba87a0df233b8762e43b742afe8e44a77a60c.camel@codeconstruct.com.au> > On Mon, 2023-12-11 at 17:22 +0700, Quan Nguyen wrote: > > Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in > > interrupt handler") acknowledges most interrupts early before the slave > > irq handler is executed, except for the "Receive Done Interrupt status" > > which is acknowledged late in the interrupt. > > However, it has been observed that the early acknowledgment of "Transmit > > Done Interrupt Status" (with ACK or NACK) often causes the interrupt to > > be raised in READ REQUEST state, that shows the > > "Unexpected ACK on read request." complaint messages. > > > > Assuming that the "Transmit Done" interrupt should only be acknowledged > > once it is truly processed, this commit fixes that issue by acknowledging > > interrupts for both ACK and NACK cases late in the interrupt handler. > > > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > > Signed-off-by: Quan Nguyen > > Reviewed-by: Andrew Jeffery So I just booted this series on v6.7-rc5 under qemu v8.2.0-rc4 and found this: ``` $ qemu-system-arm \ -M ast2600-evb \ -kernel build.aspeed_g5/arch/arm/boot/zImage \ -dtb build.aspeed_g5/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dtb \ -initrd ~/src/buildroot.org/buildroot/output/images/rootfs.cpio.xz \ -nographic 2>&1 \ | ts -s ... 00:00:03 [ 1.089187] Freeing initrd memory: 3308K 00:00:05 smbus: error: Unexpected send start condition in state 1 00:00:05 smbus: error: Unexpected write in state -1 00:00:06 [ 3.685731] aspeed-i2c-bus 1e78a400.i2c-bus: i2c bus 7 registered, irq 48 00:00:06 [ 3.688918] aspeed-i2c-bus 1e78a480.i2c-bus: i2c bus 8 registered, irq 49 00:00:06 [ 3.692326] aspeed-i2c-bus 1e78a500.i2c-bus: i2c bus 9 registered, irq 50 00:00:06 [ 3.693757] aspeed-i2c-bus 1e78a680.i2c-bus: i2c bus 12 registered, irq 51 00:00:06 [ 3.695070] aspeed-i2c-bus 1e78a700.i2c-bus: i2c bus 13 registered, irq 52 00:00:06 [ 3.696184] aspeed-i2c-bus 1e78a780.i2c-bus: i2c bus 14 registered, irq 53 00:00:06 [ 3.697144] aspeed-i2c-bus 1e78a800.i2c-bus: i2c bus 15 registered, irq 54 00:00:06 [ 3.699061] aspeed-video 1e700000.video: irq 55 00:00:06 [ 3.699254] aspeed-video 1e700000.video: assigned reserved memory node video 00:00:06 [ 3.702755] aspeed-video 1e700000.video: alloc mem size(24576) at 0xbc000000 for jpeg header 00:00:06 [ 3.706139] Driver for 1-wire Dallas network protocol. 00:00:07 smbus: error: Unexpected send start condition in state -1 00:00:07 smbus: error: Unexpected write in state -1 00:00:10 smbus: error: Unexpected send start condition in state -1 00:00:10 smbus: error: Unexpected write in state -1 00:00:12 smbus: error: Unexpected send start condition in state -1 00:00:12 smbus: error: Unexpected write in state -1 00:00:14 smbus: error: Unexpected send start condition in state -1 00:00:14 smbus: error: Unexpected write in state -1 00:00:17 smbus: error: Unexpected send start condition in state -1 00:00:17 smbus: error: Unexpected write in state -1 00:00:18 [ 14.080141] adt7475 7-002e: Error configuring attenuator bypass 00:00:19 smbus: error: Unexpected send start condition in state -1 00:00:19 smbus: error: Unexpected write in state -1 00:00:21 smbus: error: Unexpected send start condition in state -1 00:00:21 smbus: error: Unexpected write in state -1 00:00:24 smbus: error: Unexpected send start condition in state -1 00:00:24 smbus: error: Unexpected write in state -1 ``` The smbus errors do not occur if I revert this patch. Can you look into qemu to see if it's a bug in the aspeed i2c controller model's state machine? Cheers, Andrew From lkp at intel.com Fri Dec 15 09:41:46 2023 From: lkp at intel.com (kernel test robot) Date: Fri, 15 Dec 2023 06:41:46 +0800 Subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver In-Reply-To: <20231213190528.3751583-4-tmaimon77@gmail.com> References: <20231213190528.3751583-4-tmaimon77@gmail.com> Message-ID: <202312150632.EzPYbn6l-lkp@intel.com> Hi Tomer, kernel test robot noticed the following build warnings: [auto build test WARNING on soc/for-next] [also build test WARNING on robh/for-next linus/master v6.7-rc5 next-20231214] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Tomer-Maimon/dt-bindings-soc-nuvoton-Add-NPCM-BPC/20231214-030714 base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next patch link: https://lore.kernel.org/r/20231213190528.3751583-4-tmaimon77%40gmail.com patch subject: [PATCH v3 3/3] soc: nuvoton: add NPCM BPC driver config: arm64-randconfig-r123-20231215 (https://download.01.org/0day-ci/archive/20231215/202312150632.EzPYbn6l-lkp at intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce: (https://download.01.org/0day-ci/archive/20231215/202312150632.EzPYbn6l-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312150632.EzPYbn6l-lkp at intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/soc/nuvoton/npcm-bpc.c:105:25: sparse: sparse: cast to restricted __poll_t drivers/soc/nuvoton/npcm-bpc.c:108:26: sparse: sparse: cast to restricted __poll_t vim +105 drivers/soc/nuvoton/npcm-bpc.c 97 98 static __poll_t npcm_bpc_poll(struct file *file, struct poll_table_struct *pt) 99 { 100 struct npcm_bpc_channel *chan = npcm_file_to_ch(file); 101 __poll_t mask = 0; 102 103 poll_wait(file, &chan->wq, pt); 104 if (!kfifo_is_empty(&chan->fifo)) > 105 mask = (__poll_t)POLLIN; 106 107 if (chan->host_reset) { 108 mask |= (__poll_t)POLLHUP; 109 chan->host_reset = false; 110 } 111 112 return mask; 113 } 114 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From andi.shyti at kernel.org Fri Dec 15 12:42:48 2023 From: andi.shyti at kernel.org (Andi Shyti) Date: Fri, 15 Dec 2023 02:42:48 +0100 Subject: [PATCH v4 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231211102217.2436294-2-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-2-quan@os.amperecomputing.com> Message-ID: <20231215014248.6f7sqh6n4kmhe4js@zenone.zhora.eu> Hi Quan, On Mon, Dec 11, 2023 at 05:22:16PM +0700, Quan Nguyen wrote: > Some masters may drive the transfers with low enough latency between > the nak/stop phase of the current command and the start/address phase > of the following command that the interrupts are coalesced by the > time we process them. > Handle the stop conditions before processing SLAVE_MATCH to fix the > complaints that sometimes occur below. > > "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected > 0x00000086, but was 0x00000084" > > Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") > Signed-off-by: Quan Nguyen > Reviewed-by: Andrew Jeffery > Reviewed-by: Andi Shyti > --- > v4: > + Add an extra empty line before the comment [Andrew] > > Note: I'd like to keep adding Reviewed-by Andrew and Andi for this patch > eventhough there is an extra empty line added before the comment as mentioned > above. Thanks for the review. that's OK and you should. You would remove the r-b/a-b only if you do some major changes. Besides, this change was asked both by me and Andrew. Thanks, Andi From andi.shyti at kernel.org Fri Dec 15 12:45:05 2023 From: andi.shyti at kernel.org (Andi Shyti) Date: Fri, 15 Dec 2023 02:45:05 +0100 Subject: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <20231211102217.2436294-3-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-3-quan@os.amperecomputing.com> Message-ID: <20231215014505.he6ozzxd5jnjgvol@zenone.zhora.eu> Hi Quan, On Mon, Dec 11, 2023 at 05:22:17PM +0700, Quan Nguyen wrote: > Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in > interrupt handler") acknowledges most interrupts early before the slave > irq handler is executed, except for the "Receive Done Interrupt status" > which is acknowledged late in the interrupt. > However, it has been observed that the early acknowledgment of "Transmit > Done Interrupt Status" (with ACK or NACK) often causes the interrupt to > be raised in READ REQUEST state, that shows the > "Unexpected ACK on read request." complaint messages. > > Assuming that the "Transmit Done" interrupt should only be acknowledged > once it is truly processed, this commit fixes that issue by acknowledging > interrupts for both ACK and NACK cases late in the interrupt handler. > > Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") > Signed-off-by: Quan Nguyen Reviewed-by: Andi Shyti Thanks, Andi From andrew at codeconstruct.com.au Mon Dec 18 10:54:00 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Mon, 18 Dec 2023 10:24:00 +1030 Subject: openbmc/telemetry: First complaint of unresponsiveness Message-ID: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> Hello Adrian, Jozef, and Cezary, A complaint has been raised to the Technical Oversight Forum that as maintainers you collectively have not responded to several patches for openbmc/telemetry in a reasonable timeframe. Some time ago the project defined constraints on timeliness for reviews. This helps to set expectations for both contributors and maintainers. Maintainers are expected to find time to provide feedback on patches inside one month of them being pushed to Gerrit. Upon complaint, missing this deadline forms one count of unresponsiveness. If a subproject's maintainers receive three complaints of unresponsiveness in a 12 month period then the Technical Oversight Forum will seek to introduce new maintainers to the subproject. This is the first notice of a complaint of unresponsiveness for openbmc/telemetry. This notice is copied to the OpenBMC mailing list to provide community visibility. We need the process to be both public and archived to make sure we are clear and accountable in our communication. Further details and considerations of this policy are defined at the link below: https://github.com/openbmc/docs/blob/master/process/subproject-maintainership.md The complaint regarding openbmc/telemetry at: https://github.com/openbmc/technical-oversight-forum/issues/32 The specific patches identified by the complaint are: 1. 64867: build: upgrade to C++23 https://gerrit.openbmc.org/c/openbmc/telemetry/+/64867 2. 67240: clang-format: copy latest and re-format https://gerrit.openbmc.org/c/openbmc/telemetry/+/67240 3. 66007: meson_options.txt: Support for reading options from meson.options https://gerrit.openbmc.org/c/openbmc/telemetry/+/66007 If you are unable to continue with your maintenance role for openbmc/telemetry then please work with the community identify others who are capable and willing. When doing so, please consider the expectations set out in the community membership documentation: https://github.com/openbmc/docs/blob/master/community-membership.md On behalf of the Technical Oversight Forum, Andrew From potin.lai.pt at gmail.com Mon Dec 18 17:05:58 2023 From: potin.lai.pt at gmail.com (Potin Lai) Date: Mon, 18 Dec 2023 14:05:58 +0800 Subject: [PATCH linux dev-6.6 1/2] dt-bindings: Add MP2856/MP2857 voltage regulator device In-Reply-To: <20231218060559.2302459-1-potin.lai@quantatw.com> References: <20231218060559.2302459-1-potin.lai@quantatw.com> Message-ID: <20231218060559.2302459-2-potin.lai@quantatw.com> From: Peter Yin Monolithic Power Systems, Inc. (MPS) MP2856/MP2857 dual-loop, digital, multi-phase controller. Signed-off-by: Peter Yin Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/trivial-devices.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 386ebd1471d0e..c847a532283d4 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -119,6 +119,10 @@ properties: - fsl,mpl3115 # MPR121: Proximity Capacitive Touch Sensor Controller - fsl,mpr121 + # Monolithic Power Systems Inc. multi-phase controller mp2856 + - mps,mp2856 + # Monolithic Power Systems Inc. multi-phase controller mp2857 + - mps,mp2857 # Monolithic Power Systems Inc. multi-phase controller mp2888 - mps,mp2888 # Monolithic Power Systems Inc. multi-phase controller mp2971 -- 2.31.1 From potin.lai.pt at gmail.com Mon Dec 18 17:05:57 2023 From: potin.lai.pt at gmail.com (Potin Lai) Date: Mon, 18 Dec 2023 14:05:57 +0800 Subject: [PATCH linux dev-6.6 0/2] hwmon: (pmbus) Add support for MPS Multi-phase mp2856/mp2857 controller Message-ID: <20231218060559.2302459-1-potin.lai@quantatw.com> Add support for mp2856/mp2857 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a dual-loop, digital, multi-phase, modulation controller. Link: https://lore.kernel.org/all/20231108024222.2026546-1-peter.yin at quantatw.com/ Peter Yin (2): dt-bindings: Add MP2856/MP2857 voltage regulator device hwmon: (pmbus) Add support for MPS Multi-phase mp2856/mp2857 controller .../devicetree/bindings/trivial-devices.yaml | 4 + Documentation/hwmon/index.rst | 1 + Documentation/hwmon/mp2856.rst | 98 ++++ drivers/hwmon/pmbus/Kconfig | 9 + drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp2856.c | 466 ++++++++++++++++++ 6 files changed, 579 insertions(+) create mode 100644 Documentation/hwmon/mp2856.rst create mode 100644 drivers/hwmon/pmbus/mp2856.c -- 2.31.1 From potin.lai.pt at gmail.com Mon Dec 18 17:05:59 2023 From: potin.lai.pt at gmail.com (Potin Lai) Date: Mon, 18 Dec 2023 14:05:59 +0800 Subject: [PATCH linux dev-6.6 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp2856/mp2857 controller In-Reply-To: <20231218060559.2302459-1-potin.lai@quantatw.com> References: <20231218060559.2302459-1-potin.lai@quantatw.com> Message-ID: <20231218060559.2302459-3-potin.lai@quantatw.com> From: Peter Yin Add support for mp2856/mp2857 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a dual-loop, digital, multi-phase, modulation controller. Signed-off-by: Peter Yin Signed-off-by: Potin Lai --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/mp2856.rst | 98 +++++++ drivers/hwmon/pmbus/Kconfig | 9 + drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp2856.c | 466 +++++++++++++++++++++++++++++++++ 5 files changed, 575 insertions(+) create mode 100644 Documentation/hwmon/mp2856.rst create mode 100644 drivers/hwmon/pmbus/mp2856.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index fac861e2a8ab4..e45999f8e6740 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -156,6 +156,7 @@ Hardware Monitoring Kernel Drivers mcp3021 menf21bmc mlxreg-fan + mp2856 mp2888 mp2975 mp5023 diff --git a/Documentation/hwmon/mp2856.rst b/Documentation/hwmon/mp2856.rst new file mode 100644 index 0000000000000..af625c22b6ea7 --- /dev/null +++ b/Documentation/hwmon/mp2856.rst @@ -0,0 +1,98 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver mp2856 +==================== + +Supported chips: + + * MPS MP2856 + + Prefix: 'mp2856' + + * MPS MP2857 + + Prefix: 'mp2857' + +Author: + + Peter Yin + +Description +----------- + +This driver implements support for Monolithic Power Systems, Inc. (MPS) +vendor dual-loop, digital, multi-phase controller MP2856/MP2857 + +This device: + +- Supports up to two power rail. +- Supports two pages 0 and 1 for and also pages 2 for configuration. +- Can configured VOUT readout in direct or VID format and allows + setting of different formats on rails 1 and 2. For VID the following + protocols are available: AMD SVI3 mode with 5-mV/LSB. + +Device supports: + +- SVID interface. +- AVSBus interface. + +Device compliant with: + +- PMBus rev 1.3 interface. + +Device supports direct format for reading output current, output voltage, +input and output power and temperature. +Device supports linear format for reading input voltage and input power. +Device supports VID and direct formats for reading output voltage. +The below VID modes are supported: AMD SVI3. + +The driver provides the following sysfs attributes for current measurements: + +- indexes 1 for "iin"; +- indexes 2, 3 for "iout"; + +**curr[1-3]_alarm** + +**curr[1-3]_input** + +**curr[1-3]_label** + +The driver provides the following sysfs attributes for voltage measurements. + +- indexes 1 for "vin"; +- indexes 2, 3 for "vout"; + +**in[1-3]_crit** + +**in[1-3]_crit_alarm** + +**in[1-3]_input** + +**in[1-3]_label** + +**in[1-3]_lcrit** + +**in[1-3]_lcrit_alarm** + +The driver provides the following sysfs attributes for power measurements. + +- indexes 1 for "pin"; +- indexes 2, 3 for "pout"; + +**power[1-3]_alarm** + +**power[1-3]_input** + +**power[1-3]_label** + +The driver provides the following sysfs attributes for temperature measurements. + +**temp[1-2]_crit** + +**temp[1-2]_crit_alarm** + +**temp[1-2]_input** + +**temp[1-2]_max** + +**temp[1-2]_max_alarm** diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 02208d76e8223..95013c95f258a 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -308,6 +308,15 @@ config SENSORS_MAX8688 This driver can also be built as a module. If so, the module will be called max8688. +config SENSORS_MP2856 + tristate "MPS MP2856" + help + If you say yes here you get hardware monitoring support for MPS + MP2856 MP2857 Dual Loop Digital Multi-Phase Controller. + + This driver can also be built as a module. If so, the module will + be called mp2856. + config SENSORS_MP2888 tristate "MPS MP2888" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index eea38c77ed1db..cf8a767445456 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -33,6 +33,7 @@ obj-$(CONFIG_SENSORS_MAX20751) += max20751.o obj-$(CONFIG_SENSORS_MAX31785) += max31785.o obj-$(CONFIG_SENSORS_MAX34440) += max34440.o obj-$(CONFIG_SENSORS_MAX8688) += max8688.o +obj-$(CONFIG_SENSORS_MP2856) += mp2856.o obj-$(CONFIG_SENSORS_MP2888) += mp2888.o obj-$(CONFIG_SENSORS_MP2975) += mp2975.o obj-$(CONFIG_SENSORS_MP5023) += mp5023.o diff --git a/drivers/hwmon/pmbus/mp2856.c b/drivers/hwmon/pmbus/mp2856.c new file mode 100644 index 0000000000000..6969350f5d7d4 --- /dev/null +++ b/drivers/hwmon/pmbus/mp2856.c @@ -0,0 +1,466 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Hardware monitoring driver for MPS2856/2857 + * Monolithic Power Systems VR Controllers + * + * Copyright (C) 2023 Quanta Computer lnc. + */ + +#include +#include +#include +#include +#include +#include +#include "pmbus.h" + +/* Vendor specific registers. */ +#define MP2856_MFR_VR_MULTI_CONFIG_R1 0x0d +#define MP2856_MFR_VR_MULTI_CONFIG_R2 0x1d + +#define MP2856_MUL1_BOOT_SR_R2 0x10 +#define MP2856_VR_ACTIVE BIT(15) + +#define MP2856_MFR_VR_CONFIG2 0x5e +#define MP2856_VOUT_MODE BIT(11) + +#define MP2856_MFR_VR_CONFIG1 0x68 +#define MP2856_DRMOS_KCS GENMASK(13, 12) + +#define MP2856_MFR_READ_CS1_2_R1 0x82 +#define MP2856_MFR_READ_CS3_4_R1 0x83 +#define MP2856_MFR_READ_CS5_6_R1 0x84 +#define MP2856_MFR_READ_CS7_8_R1 0x85 +#define MP2856_MFR_READ_CS9_10_R1 0x86 +#define MP2856_MFR_READ_CS11_12_R1 0x87 + +#define MP2856_MFR_READ_CS1_2_R2 0x85 +#define MP2856_MFR_READ_CS3_4_R2 0x86 +#define MP2856_MFR_READ_CS5_6_R2 0x87 + +#define MP2856_MAX_PHASE_RAIL1 8 +#define MP2856_MAX_PHASE_RAIL2 4 + +#define MP2857_MAX_PHASE_RAIL1 12 +#define MP2857_MAX_PHASE_RAIL2 4 + +#define MP2856_PAGE_NUM 2 + +enum chips { mp2856 = 1, mp2857 }; + +static const int mp2856_max_phases[][MP2856_PAGE_NUM] = { + [mp2856] = { MP2856_MAX_PHASE_RAIL1, MP2856_MAX_PHASE_RAIL2 }, + [mp2857] = { MP2857_MAX_PHASE_RAIL1, MP2857_MAX_PHASE_RAIL2 }, +}; + +static const struct i2c_device_id mp2856_id[] = { + {"mp2856", mp2856}, + {"mp2857", mp2857}, + {} +}; + +MODULE_DEVICE_TABLE(i2c, mp2856_id); + +struct mp2856_data { + struct pmbus_driver_info info; + int vout_format[MP2856_PAGE_NUM]; + int curr_sense_gain[MP2856_PAGE_NUM]; + int max_phases[MP2856_PAGE_NUM]; + enum chips chip_id; +}; + +#define to_mp2856_data(x) container_of(x, struct mp2856_data, info) + +#define MAX_LIN_MANTISSA (1023 * 1000) +#define MIN_LIN_MANTISSA (511 * 1000) + +static u16 val2linear11(s64 val) +{ + s16 exponent = 0, mantissa; + bool negative = false; + + if (val == 0) + return 0; + + if (val < 0) { + negative = true; + val = -val; + } + + /* Reduce large mantissa until it fits into 10 bit */ + while (val >= MAX_LIN_MANTISSA && exponent < 15) { + exponent++; + val >>= 1; + } + /* Increase small mantissa to improve precision */ + while (val < MIN_LIN_MANTISSA && exponent > -15) { + exponent--; + val <<= 1; + } + + /* Convert mantissa from milli-units to units */ + mantissa = clamp_val(DIV_ROUND_CLOSEST_ULL(val, 1000), 0, 0x3ff); + + /* restore sign */ + if (negative) + mantissa = -mantissa; + + /* Convert to 5 bit exponent, 11 bit mantissa */ + return (mantissa & 0x7ff) | ((exponent << 11) & 0xf800); +} + +static int +mp2856_read_word_helper(struct i2c_client *client, int page, int phase, u8 reg, + u16 mask) +{ + int ret = pmbus_read_word_data(client, page, phase, reg); + + return (ret > 0) ? ret & mask : ret; +} + +static int +mp2856_read_vout(struct i2c_client *client, struct mp2856_data *data, int page, + int phase, u8 reg) +{ + int ret; + + ret = mp2856_read_word_helper(client, page, phase, reg, + GENMASK(9, 0)); + if (ret < 0) + return ret; + + /* convert vout result to direct format */ + ret = (data->vout_format[page] == vid) ? + ((ret + 49) * 5) : ((ret * 1000) >> 8); + + return ret; +} + +static int +mp2856_read_phase(struct i2c_client *client, struct mp2856_data *data, + int page, int phase, u8 reg) +{ + int ret; + int val; + + ret = pmbus_read_word_data(client, page, phase, reg); + if (ret < 0) + return ret; + + if (!((phase + 1) % MP2856_PAGE_NUM)) + ret >>= 8; + ret &= 0xff; + + /* + * Output value is calculated as: (READ_CSx * 12.5mV - 1.23V) / (Kcs * Rcs) + */ + val = (ret * 125) - 12300; + + return val2linear11(val); +} + +static int +mp2856_read_phases(struct i2c_client *client, struct mp2856_data *data, + int page, int phase) +{ + int ret; + + if (page == 0) { + switch (phase) { + case 0 ... 1: + ret = mp2856_read_phase(client, data, page, phase, + MP2856_MFR_READ_CS1_2_R1); + break; + case 2 ... 3: + ret = mp2856_read_phase(client, data, page, phase, + MP2856_MFR_READ_CS3_4_R1); + break; + case 4 ... 5: + ret = mp2856_read_phase(client, data, page, phase, + MP2856_MFR_READ_CS5_6_R1); + break; + case 6 ... 7: + ret = mp2856_read_phase(client, data, page, phase, + MP2856_MFR_READ_CS7_8_R1); + break; + default: + return -ENODATA; + } + } else { + switch (phase) { + case 0 ... 1: + ret = mp2856_read_phase(client, data, page, phase, + MP2856_MFR_READ_CS1_2_R2); + break; + case 2 ... 3: + ret = mp2856_read_phase(client, data, page, phase, + MP2856_MFR_READ_CS1_2_R2); + break; + default: + return -ENODATA; + } + } + return ret; +} + +static int +mp2856_read_word_data(struct i2c_client *client, int page, + int phase, int reg) +{ + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); + struct mp2856_data *data = to_mp2856_data(info); + int ret; + + switch (reg) { + case PMBUS_READ_VOUT: + ret = mp2856_read_vout(client, data, page, phase, reg); + break; + case PMBUS_READ_IOUT: + if (phase != 0xff) + ret = mp2856_read_phases(client, data, page, phase); + else + ret = pmbus_read_word_data(client, page, phase, reg); + break; + default: + return -ENODATA; + } + + return ret; +} + +static int +mp2856_read_byte_data(struct i2c_client *client, int page, int reg) +{ + switch (reg) { + case PMBUS_VOUT_MODE: + /* Enforce VOUT direct format. */ + return PB_VOUT_MODE_DIRECT; + default: + return -ENODATA; + } +} + +static int +mp2856_identify_multiphase(struct i2c_client *client, u8 reg, u8 max_phase, + u16 mask) +{ + int ret; + + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2); + if (ret < 0) + return ret; + + ret = i2c_smbus_read_word_data(client, reg); + if (ret < 0) + return ret; + + ret &= mask; + return (ret >= max_phase) ? max_phase : ret; +} + +static int +mp2856_identify_multiphase_rail1(struct i2c_client *client, + struct mp2856_data *data) +{ + int ret, i; + + ret = mp2856_identify_multiphase(client, MP2856_MFR_VR_MULTI_CONFIG_R1, + MP2856_MAX_PHASE_RAIL1, GENMASK(3, 0)); + if (ret < 0) + return ret; + + data->info.phases[0] = (ret > data->max_phases[0]) ? + data->max_phases[0] : ret; + + for (i = 0 ; i < data->info.phases[0]; i++) + data->info.pfunc[i] |= PMBUS_HAVE_IOUT; + + return 0; +} + +static int +mp2856_identify_multiphase_rail2(struct i2c_client *client, + struct mp2856_data *data) +{ + int ret, i; + + ret = mp2856_identify_multiphase(client, MP2856_MFR_VR_MULTI_CONFIG_R2, + MP2856_MAX_PHASE_RAIL2, GENMASK(2, 0)); + if (ret < 0) + return ret; + + data->info.phases[1] = (ret > data->max_phases[1]) ? + data->max_phases[1] : ret; + + for (i = 0 ; i < data->info.phases[0]; i++) + data->info.pfunc[i] |= PMBUS_HAVE_IOUT; + + return 0; +} + +static int +mp2856_current_sense_gain_get(struct i2c_client *client, + struct mp2856_data *data) +{ + int i, ret; + + /* + * Obtain DrMOS current sense gain of power stage from the register + * MP2856_MFR_VR_CONFIG1, bits 13-12. The value is selected as below: + * 00b - 5?A/A, 01b - 8.5?A/A, 10b - 9.7?A/A, 11b - 10?A/A. Other + * values are invalid. + */ + for (i = 0 ; i < data->info.pages; i++) { + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); + if (ret < 0) + return ret; + ret = i2c_smbus_read_word_data(client, + MP2856_MFR_VR_CONFIG1); + if (ret < 0) + return ret; + + switch ((ret & MP2856_DRMOS_KCS) >> 12) { + case 0: + data->curr_sense_gain[i] = 50; + break; + case 1: + data->curr_sense_gain[i] = 85; + break; + case 2: + data->curr_sense_gain[i] = 97; + break; + default: + data->curr_sense_gain[i] = 100; + break; + } + } + return 0; +} + +static int +mp2856_identify_vout_format(struct i2c_client *client, + struct mp2856_data *data) +{ + int i, ret; + + for (i = 0; i < data->info.pages; i++) { + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); + if (ret < 0) + return ret; + + ret = i2c_smbus_read_word_data(client, MP2856_MFR_VR_CONFIG2); + if (ret < 0) + return ret; + + data->vout_format[i] = (ret & MP2856_VOUT_MODE) ? linear : vid; + } + return 0; +} + +static bool +mp2856_is_rail2_active(struct i2c_client *client) +{ + int ret; + + ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2); + if (ret < 0) + return true; + + ret = i2c_smbus_read_word_data(client, MP2856_MUL1_BOOT_SR_R2); + if (ret < 0) + return true; + + return (ret & MP2856_VR_ACTIVE) ? true : false; +} + +static struct pmbus_driver_info mp2856_info = { + .pages = MP2856_PAGE_NUM, + .format[PSC_VOLTAGE_IN] = linear, + .format[PSC_VOLTAGE_OUT] = direct, + .format[PSC_TEMPERATURE] = linear, + .format[PSC_CURRENT_IN] = linear, + .format[PSC_CURRENT_OUT] = linear, + .format[PSC_POWER] = linear, + .m[PSC_VOLTAGE_OUT] = 1, + .R[PSC_VOLTAGE_OUT] = 3, + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | + PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | + PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_POUT | + PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT, + .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT | + PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT | PMBUS_HAVE_TEMP, + .read_byte_data = mp2856_read_byte_data, + .read_word_data = mp2856_read_word_data, +}; + +static int mp2856_probe(struct i2c_client *client) +{ + struct pmbus_driver_info *info; + struct mp2856_data *data; + int ret; + + data = devm_kzalloc(&client->dev, sizeof(struct mp2856_data), + GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->chip_id = (enum chips)(uintptr_t)i2c_get_match_data(client); + + memcpy(data->max_phases, mp2856_max_phases[data->chip_id], + sizeof(data->max_phases)); + + memcpy(&data->info, &mp2856_info, sizeof(*info)); + info = &data->info; + + /* Identify multiphase configuration. */ + ret = mp2856_identify_multiphase_rail1(client, data); + if (ret < 0) + return ret; + + if (mp2856_is_rail2_active(client)) { + ret = mp2856_identify_multiphase_rail2(client, data); + if (ret < 0) + return ret; + } else { + /* rail2 is not active */ + info->pages = 1; + } + + /* Obtain current sense gain of power stage. */ + ret = mp2856_current_sense_gain_get(client, data); + if (ret) + return ret; + + /* Identify vout format. */ + ret = mp2856_identify_vout_format(client, data); + if (ret) + return ret; + + /* set the device to page 0 */ + i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); + + return pmbus_do_probe(client, info); +} + +static const struct of_device_id __maybe_unused mp2856_of_match[] = { + {.compatible = "mps,mp2856", .data = (void *)mp2856}, + {.compatible = "mps,mp2857", .data = (void *)mp2857}, + {} +}; +MODULE_DEVICE_TABLE(of, mp2856_of_match); + +static struct i2c_driver mp2856_driver = { + .driver = { + .name = "mp2856", + .of_match_table = mp2856_of_match, + }, + .probe = mp2856_probe, + .id_table = mp2856_id, +}; + +module_i2c_driver(mp2856_driver); + +MODULE_AUTHOR("Peter Yin "); +MODULE_DESCRIPTION("PMBus driver for MPS MP2856/MP2857 device"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(PMBUS); -- 2.31.1 From quan at os.amperecomputing.com Mon Dec 18 19:45:56 2023 From: quan at os.amperecomputing.com (Quan Nguyen) Date: Mon, 18 Dec 2023 15:45:56 +0700 Subject: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <54cba87a0df233b8762e43b742afe8e44a77a60c.camel@codeconstruct.com.au> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-3-quan@os.amperecomputing.com> <2eab42cde34723a195e7a0287db08b25f8388a3b.camel@codeconstruct.com.au> <54cba87a0df233b8762e43b742afe8e44a77a60c.camel@codeconstruct.com.au> Message-ID: <7dfc99e5-4c76-413b-aabc-81b26e26249e@os.amperecomputing.com> On 15/12/2023 05:21, Andrew Jeffery wrote: >> On Mon, 2023-12-11 at 17:22 +0700, Quan Nguyen wrote: >>> Commit 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in >>> interrupt handler") acknowledges most interrupts early before the slave >>> irq handler is executed, except for the "Receive Done Interrupt status" >>> which is acknowledged late in the interrupt. >>> However, it has been observed that the early acknowledgment of "Transmit >>> Done Interrupt Status" (with ACK or NACK) often causes the interrupt to >>> be raised in READ REQUEST state, that shows the >>> "Unexpected ACK on read request." complaint messages. >>> >>> Assuming that the "Transmit Done" interrupt should only be acknowledged >>> once it is truly processed, this commit fixes that issue by acknowledging >>> interrupts for both ACK and NACK cases late in the interrupt handler. >>> >>> Fixes: 2be6b47211e1 ("i2c: aspeed: Acknowledge most interrupts early in interrupt handler") >>> Signed-off-by: Quan Nguyen >> >> Reviewed-by: Andrew Jeffery > > So I just booted this series on v6.7-rc5 under qemu v8.2.0-rc4 and > found this: > > ``` > $ qemu-system-arm \ > -M ast2600-evb \ > -kernel build.aspeed_g5/arch/arm/boot/zImage \ > -dtb build.aspeed_g5/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dtb \ > -initrd ~/src/buildroot.org/buildroot/output/images/rootfs.cpio.xz \ > -nographic 2>&1 \ > | ts -s > ... > 00:00:03 [ 1.089187] Freeing initrd memory: 3308K > 00:00:05 smbus: error: Unexpected send start condition in state 1 > 00:00:05 smbus: error: Unexpected write in state -1 > 00:00:06 [ 3.685731] aspeed-i2c-bus 1e78a400.i2c-bus: i2c bus 7 registered, irq 48 > 00:00:06 [ 3.688918] aspeed-i2c-bus 1e78a480.i2c-bus: i2c bus 8 registered, irq 49 > 00:00:06 [ 3.692326] aspeed-i2c-bus 1e78a500.i2c-bus: i2c bus 9 registered, irq 50 > 00:00:06 [ 3.693757] aspeed-i2c-bus 1e78a680.i2c-bus: i2c bus 12 registered, irq 51 > 00:00:06 [ 3.695070] aspeed-i2c-bus 1e78a700.i2c-bus: i2c bus 13 registered, irq 52 > 00:00:06 [ 3.696184] aspeed-i2c-bus 1e78a780.i2c-bus: i2c bus 14 registered, irq 53 > 00:00:06 [ 3.697144] aspeed-i2c-bus 1e78a800.i2c-bus: i2c bus 15 registered, irq 54 > 00:00:06 [ 3.699061] aspeed-video 1e700000.video: irq 55 > 00:00:06 [ 3.699254] aspeed-video 1e700000.video: assigned reserved memory node video > 00:00:06 [ 3.702755] aspeed-video 1e700000.video: alloc mem size(24576) at 0xbc000000 for jpeg header > 00:00:06 [ 3.706139] Driver for 1-wire Dallas network protocol. > 00:00:07 smbus: error: Unexpected send start condition in state -1 > 00:00:07 smbus: error: Unexpected write in state -1 > 00:00:10 smbus: error: Unexpected send start condition in state -1 > 00:00:10 smbus: error: Unexpected write in state -1 > 00:00:12 smbus: error: Unexpected send start condition in state -1 > 00:00:12 smbus: error: Unexpected write in state -1 > 00:00:14 smbus: error: Unexpected send start condition in state -1 > 00:00:14 smbus: error: Unexpected write in state -1 > 00:00:17 smbus: error: Unexpected send start condition in state -1 > 00:00:17 smbus: error: Unexpected write in state -1 > 00:00:18 [ 14.080141] adt7475 7-002e: Error configuring attenuator bypass > 00:00:19 smbus: error: Unexpected send start condition in state -1 > 00:00:19 smbus: error: Unexpected write in state -1 > 00:00:21 smbus: error: Unexpected send start condition in state -1 > 00:00:21 smbus: error: Unexpected write in state -1 > 00:00:24 smbus: error: Unexpected send start condition in state -1 > 00:00:24 smbus: error: Unexpected write in state -1 > ``` > > The smbus errors do not occur if I revert this patch. > > Can you look into qemu to see if it's a bug in the aspeed i2c > controller model's state machine? > Thanks, Andrew, for testing these patches on qemu. I'll try to look into it to see if anything can be improved, but I have to admit that I'm not so familiar with it. This is my first time trying it on qemu. Just did these tests on real HW with waveform captured sometimes. So far I could be able to reproduce the issue and start playing around trying to understand the model. Thanks, - Quan From tmaimon77 at gmail.com Tue Dec 19 04:04:04 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Mon, 18 Dec 2023 19:04:04 +0200 Subject: [PATCH RESEND v21] clk: npcm8xx: add clock controller Message-ID: <20231218170404.910153-1-tmaimon77@gmail.com> Nuvoton Arbel BMC NPCM8XX contains an integrated clock controller which generates and supplies clocks to all modules within the BMC. Signed-off-by: Tomer Maimon Acked-by: Joel Stanley --- Addressed comments from: - Stephen Boyd : https://www.spinics.net/lists/kernel/msg5016941.html Changes since version 20: - Using regmap instead of ioremap. the clock and reset modules are sharing the same memory region and cause failure when using devm_platform_ioremap_resource function, this version uses regmap to handle shared reset and clock memory region, in case it is approved I will modify the reset driver to use the regmap as well. - Using clk_hw instead of clk_parent_data structre. - Divider clock definition to one line Changes since version 19: - Remove unnecessary free command. - Defining pr_fmt(). - Using dev_err_probe. - Return zero in the end of the probe function. Changes since version 18: - NPCM8XX clock driver did not changed from version 18 only build and tested under kernel 6.6-rc1. Changes since version 17: - NPCM8XX clock driver did not changed from version 17 only build and tested under kernel 6.5-rc3. Changes since version 16: - NPCM8XX clock driver - Using devm_kzalloc instead kzalloc. - Remove unnecessary parenthesis. - Modify incorrect spelling. Changes since version 15: - NPCM8XX clock driver - Remove unused regs parameter from npcm8xx_pll_data structure. - Using index and clk_hw parameters to set the clock parent in the clock structures. Changes since version 14: - NPCM8XX clock driver - Remove unnecessary register definitions. - Remove the internal reference clock, instead use the external DT reference clock. - rearrange the driver. - using .names parameter in DT to define clock (refclk). Changes since version 13: - NPCM8XX clock driver - Remove unnecessary definitions and add module.h define - Use in clk_parent_data struct.fw_name and .name. - Add module_exit function. - Add const to divider clock names. - Add MODULE_DESCRIPTION and MODULE_LICENSE Changes since version 12: - NPCM8XX clock driver - Use clk_parent_data in mux and div clock structure. - Add const to mux tables. - Using devm_clk_hw_register_fixed_rate function. - use only .name clk_parent_data instead .name and .fw_name. - Modify mask values in mux clocks. Changes since version 11: - NPCM8XX clock driver - Modify Kconfig help. - Modify loop variable to unsigned int. Changes since version 11: - NPCM8XX clock driver - Modify Kconfig help. - Modify loop variable to unsigned int. Changes since version 10: - NPCM8XX clock driver - Fix const warning. Changes since version 9: - NPCM8XX clock driver - Move configuration place. - Using clk_parent_data instead of parent_name - using devm_ioremap instead of ioremap. deeply sorry, I know we had a long discussion on what should the driver use, from other examples (also in other clock drivers) I see the combination of platform_get_resource and devm_ioremap are commonly used and it answer the reset and clock needs. Changes since version 8: - NPCM8XX clock driver - Move configuration place. - Add space before and aftre '{' '}'. - Handle devm_of_clk_add_hw_provider function error. Changes since version 7: - NPCM8XX clock driver - The clock and reset registers using the same memory region, due to it the clock driver should claim the ioremap directly without checking the memory region. Changes since version 5: - NPCM8XX clock driver - Remove refclk if devm_of_clk_add_hw_provider function failed. Changes since version 4: - NPCM8XX clock driver - Use the same quote in the dt-binding file. Changes since version 3: - NPCM8XX clock driver - Rename NPCM8xx clock dt-binding header file. - Remove unused structures. - Improve Handling the clocks registration. Changes since version 2: - NPCM8XX clock driver - Add debug new line. - Add 25M fixed rate clock. - Remove unused clocks and clock name from dt-binding. Changes since version 1: - NPCM8XX clock driver - Modify dt-binding. - Remove unsed definition and include. - Include alphabetically. - Use clock devm. drivers/clk/clk-npcm8xx.c | 552 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 552 insertions(+) create mode 100644 drivers/clk/clk-npcm8xx.c diff --git a/drivers/clk/clk-npcm8xx.c b/drivers/clk/clk-npcm8xx.c new file mode 100644 index 000000000000..e6c5111cc255 --- /dev/null +++ b/drivers/clk/clk-npcm8xx.c @@ -0,0 +1,552 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Nuvoton NPCM8xx Clock Generator + * All the clocks are initialized by the bootloader, so this driver allows only + * reading of current settings directly from the hardware. + * + * Copyright (C) 2020 Nuvoton Technologies + * Author: Tomer Maimon + */ + +#define pr_fmt(fmt) "npcm8xx_clk: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* npcm8xx clock registers*/ +#define NPCM8XX_CLKSEL 0x04 +#define NPCM8XX_CLKDIV1 0x08 +#define NPCM8XX_CLKDIV2 0x2C +#define NPCM8XX_CLKDIV3 0x58 +#define NPCM8XX_CLKDIV4 0x7C +#define NPCM8XX_PLLCON0 0x0C +#define NPCM8XX_PLLCON1 0x10 +#define NPCM8XX_PLLCON2 0x54 +#define NPCM8XX_PLLCONG 0x60 +#define NPCM8XX_THRTL_CNT 0xC0 + +#define PLLCON_LOKI BIT(31) +#define PLLCON_LOKS BIT(30) +#define PLLCON_FBDV GENMASK(27, 16) +#define PLLCON_OTDV2 GENMASK(15, 13) +#define PLLCON_PWDEN BIT(12) +#define PLLCON_OTDV1 GENMASK(10, 8) +#define PLLCON_INDV GENMASK(5, 0) + +struct npcm8xx_clk { + struct regmap *clk_regmap; + unsigned int offset; + const char *name; + const u32 *table; + u32 mask; + u8 shift; + unsigned long width; + unsigned long flags; + struct clk_hw hw; +}; + +#define to_npcm8xx_clk(_hw) container_of(_hw, struct npcm8xx_clk, hw) + +struct npcm8xx_clk_pll_data { + const char *name; + struct clk_parent_data parent; + unsigned int reg; + unsigned long flags; + struct clk_hw hw; +}; + +struct npcm8xx_clk_div_data { + u32 reg; + u8 shift; + u8 width; + const char *name; + const struct clk_hw *parent_hw; + unsigned long clk_divider_flags; + unsigned long flags; + int onecell_idx; + struct clk_hw hw; +}; + +struct npcm8xx_clk_mux_data { + u8 shift; + u32 mask; + const u32 *table; + const char *name; + const struct clk_parent_data *parent_data; + u8 num_parents; + unsigned long flags; + struct clk_hw hw; +}; + +/* external clock definition */ +#define NPCM8XX_CLK_S_REFCLK "refclk" + +/* pll definition */ +#define NPCM8XX_CLK_S_PLL0 "pll0" +#define NPCM8XX_CLK_S_PLL1 "pll1" +#define NPCM8XX_CLK_S_PLL2 "pll2" +#define NPCM8XX_CLK_S_PLL_GFX "pll_gfx" + +/* early divider definition */ +#define NPCM8XX_CLK_S_PLL2_DIV2 "pll2_div2" +#define NPCM8XX_CLK_S_PLL_GFX_DIV2 "pll_gfx_div2" +#define NPCM8XX_CLK_S_PLL1_DIV2 "pll1_div2" + +/* mux definition */ +#define NPCM8XX_CLK_S_CPU_MUX "cpu_mux" +#define NPCM8XX_CLK_S_PIX_MUX "gfx_pixel_mux" +#define NPCM8XX_CLK_S_SD_MUX "sd_mux" +#define NPCM8XX_CLK_S_UART_MUX "uart_mux" +#define NPCM8XX_CLK_S_SU_MUX "serial_usb_mux" +#define NPCM8XX_CLK_S_MC_MUX "mc_mux" +#define NPCM8XX_CLK_S_ADC_MUX "adc_mux" +#define NPCM8XX_CLK_S_GFX_MUX "gfx_mux" +#define NPCM8XX_CLK_S_CLKOUT_MUX "clkout_mux" +#define NPCM8XX_CLK_S_GFXM_MUX "gfxm_mux" +#define NPCM8XX_CLK_S_DVC_MUX "dvc_mux" +#define NPCM8XX_CLK_S_RG_MUX "rg_mux" +#define NPCM8XX_CLK_S_RCP_MUX "rcp_mux" + +/* div definition */ +#define NPCM8XX_CLK_S_MC "mc" +#define NPCM8XX_CLK_S_AXI "axi" +#define NPCM8XX_CLK_S_AHB "ahb" +#define NPCM8XX_CLK_S_SPI0 "spi0" +#define NPCM8XX_CLK_S_SPI1 "spi1" +#define NPCM8XX_CLK_S_SPI3 "spi3" +#define NPCM8XX_CLK_S_SPIX "spix" +#define NPCM8XX_CLK_S_APB1 "apb1" +#define NPCM8XX_CLK_S_APB2 "apb2" +#define NPCM8XX_CLK_S_APB3 "apb3" +#define NPCM8XX_CLK_S_APB4 "apb4" +#define NPCM8XX_CLK_S_APB5 "apb5" +#define NPCM8XX_CLK_S_APB19 "apb19" +#define NPCM8XX_CLK_S_TOCK "tock" +#define NPCM8XX_CLK_S_CLKOUT "clkout" +#define NPCM8XX_CLK_S_PRE_ADC "pre adc" +#define NPCM8XX_CLK_S_UART "uart" +#define NPCM8XX_CLK_S_UART2 "uart2" +#define NPCM8XX_CLK_S_TIMER "timer" +#define NPCM8XX_CLK_S_MMC "mmc" +#define NPCM8XX_CLK_S_SDHC "sdhc" +#define NPCM8XX_CLK_S_ADC "adc" +#define NPCM8XX_CLK_S_GFX "gfx0_gfx1_mem" +#define NPCM8XX_CLK_S_USBIF "serial_usbif" +#define NPCM8XX_CLK_S_USB_HOST "usb_host" +#define NPCM8XX_CLK_S_USB_BRIDGE "usb_bridge" +#define NPCM8XX_CLK_S_PCI "pci" +#define NPCM8XX_CLK_S_TH "th" +#define NPCM8XX_CLK_S_ATB "atb" +#define NPCM8XX_CLK_S_PRE_CLK "pre_clk" +#define NPCM8XX_CLK_S_RG "rg" +#define NPCM8XX_CLK_S_RCP "rcp" + +static struct clk_hw hw_pll1_div2, hw_pll2_div2, hw_gfx_div2, hw_pre_clk; +static struct npcm8xx_clk_pll_data npcm8xx_pll_clks[] = { + { NPCM8XX_CLK_S_PLL0, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON0, 0 }, + { NPCM8XX_CLK_S_PLL1, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON1, 0 }, + { NPCM8XX_CLK_S_PLL2, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON2, 0 }, + { NPCM8XX_CLK_S_PLL_GFX, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCONG, 0 }, +}; + +static const u32 cpuck_mux_table[] = { 0, 1, 2, 7 }; +static const struct clk_parent_data cpuck_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 }, + { .hw = &npcm8xx_pll_clks[2].hw } +}; + +static const u32 pixcksel_mux_table[] = { 0, 2 }; +static const struct clk_parent_data pixcksel_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[3].hw }, + { .index = 0 } +}; + +static const u32 default_mux_table[] = { 0, 1, 2, 3 }; +static const struct clk_parent_data default_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 }, + { .hw = &hw_pll2_div2 } +}; + +static const u32 sucksel_mux_table[] = { 2, 3 }; +static const struct clk_parent_data sucksel_mux_parents[] = { + { .index = 0 }, + { .hw = &hw_pll2_div2 } +}; + +static const u32 mccksel_mux_table[] = { 0, 2 }; +static const struct clk_parent_data mccksel_mux_parents[] = { + { .hw = &hw_pll1_div2 }, + { .index = 0 } +}; + +static const u32 clkoutsel_mux_table[] = { 0, 1, 2, 3, 4 }; +static const struct clk_parent_data clkoutsel_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 }, + { .hw = &hw_gfx_div2 }, + { .hw = &hw_pll2_div2 } +}; + +static const u32 gfxmsel_mux_table[] = { 2, 3 }; +static const struct clk_parent_data gfxmsel_mux_parents[] = { + { .index = 0 }, + { .hw = &npcm8xx_pll_clks[2].hw } +}; + +static const u32 dvcssel_mux_table[] = { 2, 3 }; +static const struct clk_parent_data dvcssel_mux_parents[] = { + { .index = 0 }, + { .hw = &npcm8xx_pll_clks[2].hw } +}; + +static const u32 default3_mux_table[] = { 0, 1, 2 }; +static const struct clk_parent_data default3_mux_parents[] = { + { .hw = &npcm8xx_pll_clks[0].hw }, + { .hw = &npcm8xx_pll_clks[1].hw }, + { .index = 0 } +}; + +static struct npcm8xx_clk_mux_data npcm8xx_muxes[] = { + { 0, 7, cpuck_mux_table, NPCM8XX_CLK_S_CPU_MUX, cpuck_mux_parents, + ARRAY_SIZE(cpuck_mux_parents), CLK_IS_CRITICAL }, + { 4, 3, pixcksel_mux_table, NPCM8XX_CLK_S_PIX_MUX, pixcksel_mux_parents, + ARRAY_SIZE(pixcksel_mux_parents), 0 }, + { 6, 3, default_mux_table, NPCM8XX_CLK_S_SD_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 8, 3, default_mux_table, NPCM8XX_CLK_S_UART_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 10, 3, sucksel_mux_table, NPCM8XX_CLK_S_SU_MUX, sucksel_mux_parents, + ARRAY_SIZE(sucksel_mux_parents), 0 }, + { 12, 3, mccksel_mux_table, NPCM8XX_CLK_S_MC_MUX, mccksel_mux_parents, + ARRAY_SIZE(mccksel_mux_parents), 0 }, + { 14, 3, default_mux_table, NPCM8XX_CLK_S_ADC_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 16, 3, default_mux_table, NPCM8XX_CLK_S_GFX_MUX, default_mux_parents, + ARRAY_SIZE(default_mux_parents), 0 }, + { 18, 7, clkoutsel_mux_table, NPCM8XX_CLK_S_CLKOUT_MUX, clkoutsel_mux_parents, + ARRAY_SIZE(clkoutsel_mux_parents), 0 }, + { 21, 3, gfxmsel_mux_table, NPCM8XX_CLK_S_GFXM_MUX, gfxmsel_mux_parents, + ARRAY_SIZE(gfxmsel_mux_parents), 0 }, + { 23, 3, dvcssel_mux_table, NPCM8XX_CLK_S_DVC_MUX, dvcssel_mux_parents, + ARRAY_SIZE(dvcssel_mux_parents), 0 }, + { 25, 3, default3_mux_table, NPCM8XX_CLK_S_RG_MUX, default3_mux_parents, + ARRAY_SIZE(default3_mux_parents), 0 }, + { 27, 3, default3_mux_table, NPCM8XX_CLK_S_RCP_MUX, default3_mux_parents, + ARRAY_SIZE(default3_mux_parents), 0 }, +}; + +static struct npcm8xx_clk_div_data npcm8xx_pre_divs[] = { + { NPCM8XX_CLKDIV1, 21, 5, NPCM8XX_CLK_S_PRE_ADC, &npcm8xx_muxes[6].hw, CLK_DIVIDER_READ_ONLY, 0, -1 }, + { NPCM8XX_CLKDIV1, 26, 2, NPCM8XX_CLK_S_AHB, &hw_pre_clk, CLK_DIVIDER_READ_ONLY, CLK_IS_CRITICAL, NPCM8XX_CLK_AHB }, +}; + +/* configurable dividers: */ +static struct npcm8xx_clk_div_data npcm8xx_divs[] = { + { NPCM8XX_CLKDIV1, 28, 3, NPCM8XX_CLK_S_ADC, &npcm8xx_pre_divs[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_ADC }, + { NPCM8XX_CLKDIV1, 16, 5, NPCM8XX_CLK_S_UART, &npcm8xx_muxes[3].hw, 0, 0, NPCM8XX_CLK_UART }, + { NPCM8XX_CLKDIV1, 11, 5, NPCM8XX_CLK_S_MMC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_MMC }, + { NPCM8XX_CLKDIV1, 6, 5, NPCM8XX_CLK_S_SPI3, &npcm8xx_pre_divs[1].hw, 0, 0, NPCM8XX_CLK_SPI3 }, + { NPCM8XX_CLKDIV1, 2, 4, NPCM8XX_CLK_S_PCI, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_PCI }, + + { NPCM8XX_CLKDIV2, 30, 2, NPCM8XX_CLK_S_APB4, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB4 }, + { NPCM8XX_CLKDIV2, 28, 2, NPCM8XX_CLK_S_APB3, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB3 }, + { NPCM8XX_CLKDIV2, 26, 2, NPCM8XX_CLK_S_APB2, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB2 }, + { NPCM8XX_CLKDIV2, 24, 2, NPCM8XX_CLK_S_APB1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB1 }, + { NPCM8XX_CLKDIV2, 22, 2, NPCM8XX_CLK_S_APB5, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB5 }, + { NPCM8XX_CLKDIV2, 16, 5, NPCM8XX_CLK_S_CLKOUT, &npcm8xx_muxes[8].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_CLKOUT }, + { NPCM8XX_CLKDIV2, 13, 3, NPCM8XX_CLK_S_GFX, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_GFX }, + { NPCM8XX_CLKDIV2, 8, 5, NPCM8XX_CLK_S_USB_BRIDGE, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU }, + { NPCM8XX_CLKDIV2, 4, 4, NPCM8XX_CLK_S_USB_HOST, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU48 }, + { NPCM8XX_CLKDIV2, 0, 4, NPCM8XX_CLK_S_SDHC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SDHC }, + + { NPCM8XX_CLKDIV3, 16, 8, NPCM8XX_CLK_S_SPI1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI1 }, + { NPCM8XX_CLKDIV3, 11, 5, NPCM8XX_CLK_S_UART2, &npcm8xx_muxes[3].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_UART2 }, + { NPCM8XX_CLKDIV3, 6, 5, NPCM8XX_CLK_S_SPI0, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI0 }, + { NPCM8XX_CLKDIV3, 1, 5, NPCM8XX_CLK_S_SPIX, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPIX }, + + { NPCM8XX_CLKDIV4, 28, 4, NPCM8XX_CLK_S_RG, &npcm8xx_muxes[11].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RG }, + { NPCM8XX_CLKDIV4, 12, 4, NPCM8XX_CLK_S_RCP, &npcm8xx_muxes[12].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RCP }, + + { NPCM8XX_THRTL_CNT, 0, 2, NPCM8XX_CLK_S_TH, &npcm8xx_muxes[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_TH }, +}; + +static struct clk_hw * +npcm8xx_clk_register(struct device *dev, const char *name, + struct regmap *clk_regmap, unsigned int offset, + unsigned long flags, const struct clk_ops *npcm8xx_clk_ops, + const struct clk_parent_data *parent_data, + const struct clk_hw *parent_hw, u8 num_parents, + u8 shift, u32 mask, unsigned long width, + const u32 *table, unsigned long clk_flags) +{ + struct npcm8xx_clk *clk; + struct clk_init_data init = {}; + int ret; + + clk = devm_kzalloc(dev, sizeof(*clk), GFP_KERNEL); + if (!clk) + return ERR_PTR(-ENOMEM); + + init.name = name; + init.ops = npcm8xx_clk_ops; + init.parent_data = parent_data; + init.parent_hws = parent_hw ? &parent_hw : NULL; + init.num_parents = num_parents; + init.flags = flags; + + clk->clk_regmap = clk_regmap; + clk->hw.init = &init; + clk->offset = offset; + clk->shift = shift; + clk->mask = mask; + clk->width = width; + clk->table = table; + clk->flags = clk_flags; + + ret = devm_clk_hw_register(dev, &clk->hw); + if (ret) + return ERR_PTR(ret); + + return &clk->hw; +} + +static unsigned long npcm8xx_clk_pll_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct npcm8xx_clk *pll = to_npcm8xx_clk(hw); + unsigned long fbdv, indv, otdv1, otdv2; + unsigned int val; + u64 ret; + + if (parent_rate == 0) { + pr_debug("%s: parent rate is zero\n", __func__); + return 0; + } + + regmap_read(pll->clk_regmap, pll->offset, &val); + + indv = FIELD_GET(PLLCON_INDV, val); + fbdv = FIELD_GET(PLLCON_FBDV, val); + otdv1 = FIELD_GET(PLLCON_OTDV1, val); + otdv2 = FIELD_GET(PLLCON_OTDV2, val); + + ret = (u64)parent_rate * fbdv; + do_div(ret, indv * otdv1 * otdv2); + + return ret; +} + +static const struct clk_ops npcm8xx_clk_pll_ops = { + .recalc_rate = npcm8xx_clk_pll_recalc_rate, +}; + +static u8 npcm8xx_clk_mux_get_parent(struct clk_hw *hw) +{ + struct npcm8xx_clk *mux = to_npcm8xx_clk(hw); + u32 val; + + regmap_read(mux->clk_regmap, mux->offset, &val); + val = val >> mux->shift; + val &= mux->mask; + + return clk_mux_val_to_index(hw, mux->table, mux->flags, val); +} + +static const struct clk_ops npcm8xx_clk_mux_ops = { + .get_parent = npcm8xx_clk_mux_get_parent, +}; + +static unsigned long npcm8xx_clk_div_get_parent(struct clk_hw *hw, + unsigned long parent_rate) +{ + struct npcm8xx_clk *div = to_npcm8xx_clk(hw); + unsigned int val; + + regmap_read(div->clk_regmap, div->offset, &val); + val = val >> div->shift; + val &= clk_div_mask(div->width); + + return divider_recalc_rate(hw, parent_rate, val, NULL, div->flags, + div->width); +} + +static const struct clk_ops npcm8xx_clk_div_ops = { + .recalc_rate = npcm8xx_clk_div_get_parent, +}; + +static int npcm8xx_clk_probe(struct platform_device *pdev) +{ + struct clk_hw_onecell_data *npcm8xx_clk_data; + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct regmap *clk_regmap; + struct clk_hw *hw; + unsigned int i; + + npcm8xx_clk_data = devm_kzalloc(dev, struct_size(npcm8xx_clk_data, hws, + NPCM8XX_NUM_CLOCKS), + GFP_KERNEL); + if (!npcm8xx_clk_data) + return -ENOMEM; + + clk_regmap = syscon_regmap_lookup_by_phandle(np, "nuvoton,sysclk"); + if (IS_ERR(clk_regmap)) { + dev_err(&pdev->dev, "Failed to find nuvoton,sysclk\n"); + return PTR_ERR(clk_regmap); + } + + npcm8xx_clk_data->num = NPCM8XX_NUM_CLOCKS; + + for (i = 0; i < NPCM8XX_NUM_CLOCKS; i++) + npcm8xx_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); + + /* Register plls */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_pll_clks); i++) { + struct npcm8xx_clk_pll_data *pll_clk = &npcm8xx_pll_clks[i]; + + hw = npcm8xx_clk_register(dev, pll_clk->name, clk_regmap, + pll_clk->reg, pll_clk->flags, + &npcm8xx_clk_pll_ops, &pll_clk->parent, + NULL, 1, 0, 0, 0, NULL, 0); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pll\n"); + pll_clk->hw = *hw; + } + + /* Register fixed dividers */ + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PLL1_DIV2, + NPCM8XX_CLK_S_PLL1, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register fixed div\n"); + hw_pll1_div2 = *hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PLL2_DIV2, + NPCM8XX_CLK_S_PLL2, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pll2 div2\n"); + hw_pll2_div2 = *hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PLL_GFX_DIV2, + NPCM8XX_CLK_S_PLL_GFX, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register gfx div2\n"); + hw_gfx_div2 = *hw; + + /* Register muxes */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_muxes); i++) { + struct npcm8xx_clk_mux_data *mux_data = &npcm8xx_muxes[i]; + + hw = npcm8xx_clk_register(dev, mux_data->name, clk_regmap, + NPCM8XX_CLKSEL, mux_data->flags, + &npcm8xx_clk_mux_ops, + mux_data->parent_data, NULL, + mux_data->num_parents, + mux_data->shift, mux_data->mask, 0, + mux_data->table, 0); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register mux\n"); + mux_data->hw = *hw; + } + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_PRE_CLK, + NPCM8XX_CLK_S_CPU_MUX, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pre clk div2\n"); + hw_pre_clk = *hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_AXI, + NPCM8XX_CLK_S_TH, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register axi div2\n"); + npcm8xx_clk_data->hws[NPCM8XX_CLK_AXI] = hw; + + hw = devm_clk_hw_register_fixed_factor(dev, NPCM8XX_CLK_S_ATB, + NPCM8XX_CLK_S_AXI, 0, 1, 2); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register atb div2\n"); + npcm8xx_clk_data->hws[NPCM8XX_CLK_ATB] = hw; + + /* Register clock pre dividers specified in npcm8xx_divs */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_pre_divs); i++) { + struct npcm8xx_clk_div_data *div_data = &npcm8xx_pre_divs[i]; + + hw = npcm8xx_clk_register(dev, div_data->name, clk_regmap, + div_data->reg, div_data->flags, + &npcm8xx_clk_div_ops, NULL, + div_data->parent_hw, 1, + div_data->shift, 0, div_data->width, + NULL, div_data->clk_divider_flags); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register pre div table\n"); + div_data->hw = *hw; + + if (div_data->onecell_idx >= 0) + npcm8xx_clk_data->hws[div_data->onecell_idx] = hw; + } + + /* Register clock dividers specified in npcm8xx_divs */ + for (i = 0; i < ARRAY_SIZE(npcm8xx_divs); i++) { + struct npcm8xx_clk_div_data *div_data = &npcm8xx_divs[i]; + + hw = npcm8xx_clk_register(dev, div_data->name, clk_regmap, + div_data->reg, div_data->flags, + &npcm8xx_clk_div_ops, NULL, + div_data->parent_hw, 1, + div_data->shift, 0, div_data->width, + NULL, div_data->clk_divider_flags); + if (IS_ERR(hw)) + return dev_err_probe(dev, PTR_ERR(hw), "Can't register div table\n"); + + if (div_data->onecell_idx >= 0) + npcm8xx_clk_data->hws[div_data->onecell_idx] = hw; + } + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, + npcm8xx_clk_data); +} + +static const struct of_device_id npcm8xx_clk_dt_ids[] = { + { .compatible = "nuvoton,npcm845-clk", }, + { } +}; +MODULE_DEVICE_TABLE(of, npcm8xx_clk_dt_ids); + +static struct platform_driver npcm8xx_clk_driver = { + .probe = npcm8xx_clk_probe, + .driver = { + .name = "npcm8xx_clk", + .of_match_table = npcm8xx_clk_dt_ids, + }, +}; + +static int __init npcm8xx_clk_driver_init(void) +{ + return platform_driver_register(&npcm8xx_clk_driver); +} +arch_initcall(npcm8xx_clk_driver_init); + +static void __exit npcm8xx_clk_exit(void) +{ + platform_driver_unregister(&npcm8xx_clk_driver); +} +module_exit(npcm8xx_clk_exit); + +MODULE_DESCRIPTION("Clock driver for Nuvoton NPCM8XX BMC SoC"); +MODULE_AUTHOR("Tomer Maimon "); +MODULE_LICENSE("GPL v2"); + -- 2.34.1 From andrew at codeconstruct.com.au Tue Dec 19 10:02:45 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Tue, 19 Dec 2023 09:32:45 +1030 Subject: [PATCH v4 2/2] i2c: aspeed: Acknowledge Tx done with and without ACK irq late In-Reply-To: <7dfc99e5-4c76-413b-aabc-81b26e26249e@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-3-quan@os.amperecomputing.com> <2eab42cde34723a195e7a0287db08b25f8388a3b.camel@codeconstruct.com.au> <54cba87a0df233b8762e43b742afe8e44a77a60c.camel@codeconstruct.com.au> <7dfc99e5-4c76-413b-aabc-81b26e26249e@os.amperecomputing.com> Message-ID: <477f1e8fbed91cc1160086af1f20030e7a6d853b.camel@codeconstruct.com.au> On Mon, 2023-12-18 at 15:45 +0700, Quan Nguyen wrote: > > On 15/12/2023 05:21, Andrew Jeffery wrote: > > > > ``` > > $ qemu-system-arm \ > > -M ast2600-evb \ > > -kernel build.aspeed_g5/arch/arm/boot/zImage \ > > -dtb build.aspeed_g5/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dtb \ > > -initrd ~/src/buildroot.org/buildroot/output/images/rootfs.cpio.xz \ > > -nographic 2>&1 \ > > | ts -s > > ... > > 00:00:03 [ 1.089187] Freeing initrd memory: 3308K > > 00:00:05 smbus: error: Unexpected send start condition in state 1 > > 00:00:05 smbus: error: Unexpected write in state -1 > > 00:00:06 [ 3.685731] aspeed-i2c-bus 1e78a400.i2c-bus: i2c bus 7 registered, irq 48 > > 00:00:06 [ 3.688918] aspeed-i2c-bus 1e78a480.i2c-bus: i2c bus 8 registered, irq 49 > > 00:00:06 [ 3.692326] aspeed-i2c-bus 1e78a500.i2c-bus: i2c bus 9 registered, irq 50 > > 00:00:06 [ 3.693757] aspeed-i2c-bus 1e78a680.i2c-bus: i2c bus 12 registered, irq 51 > > 00:00:06 [ 3.695070] aspeed-i2c-bus 1e78a700.i2c-bus: i2c bus 13 registered, irq 52 > > 00:00:06 [ 3.696184] aspeed-i2c-bus 1e78a780.i2c-bus: i2c bus 14 registered, irq 53 > > 00:00:06 [ 3.697144] aspeed-i2c-bus 1e78a800.i2c-bus: i2c bus 15 registered, irq 54 > > 00:00:06 [ 3.699061] aspeed-video 1e700000.video: irq 55 > > 00:00:06 [ 3.699254] aspeed-video 1e700000.video: assigned reserved memory node video > > 00:00:06 [ 3.702755] aspeed-video 1e700000.video: alloc mem size(24576) at 0xbc000000 for jpeg header > > 00:00:06 [ 3.706139] Driver for 1-wire Dallas network protocol. > > 00:00:07 smbus: error: Unexpected send start condition in state -1 > > 00:00:07 smbus: error: Unexpected write in state -1 > > 00:00:10 smbus: error: Unexpected send start condition in state -1 > > 00:00:10 smbus: error: Unexpected write in state -1 > > 00:00:12 smbus: error: Unexpected send start condition in state -1 > > 00:00:12 smbus: error: Unexpected write in state -1 > > 00:00:14 smbus: error: Unexpected send start condition in state -1 > > 00:00:14 smbus: error: Unexpected write in state -1 > > 00:00:17 smbus: error: Unexpected send start condition in state -1 > > 00:00:17 smbus: error: Unexpected write in state -1 > > 00:00:18 [ 14.080141] adt7475 7-002e: Error configuring attenuator bypass > > 00:00:19 smbus: error: Unexpected send start condition in state -1 > > 00:00:19 smbus: error: Unexpected write in state -1 > > 00:00:21 smbus: error: Unexpected send start condition in state -1 > > 00:00:21 smbus: error: Unexpected write in state -1 > > 00:00:24 smbus: error: Unexpected send start condition in state -1 > > 00:00:24 smbus: error: Unexpected write in state -1 > > ``` > > > > The smbus errors do not occur if I revert this patch. > > > > Can you look into qemu to see if it's a bug in the aspeed i2c > > controller model's state machine? > > > > Thanks, Andrew, for testing these patches on qemu. > > I'll try to look into it to see if anything can be improved, but I have > to admit that I'm not so familiar with it. This is my first time trying > it on qemu. Just did these tests on real HW with waveform captured > sometimes. > > So far I could be able to reproduce the issue and start playing around > trying to understand the model. > So `$ git grep -lF 'Unexpected write in state'` leads us to hw/i2c/smbus_slave.c:193. From the switch statement there and the log output above dev->mode must be SMBUS_CONFUSED: https://gitlab.com/qemu-project/qemu/-/blob/039afc5ef7367fbc8fb475580c291c2655e856cb/hw/i2c/smbus_slave.c#L35-L41 The prior log message was: ``` 00:00:05 smbus: error: Unexpected send start condition in state 1 ``` So we entered SMBUS_CONFUSED from SMBUS_WRITE_DATA. Given the log output above it suggests the master model is failing to send an I2C_FINISH prior to I2C_START_SEND, as that log message is emitted from `dev->mode != SMBUS_IDLE` when the slave sees an `I2C_START_SEND`. Perhaps the M_STOP_CMD handling needs to go above the M_START_CMD handling in aspeed_i2c_bus_handle_cmd()? https://gitlab.com/qemu-project/qemu/-/blob/039afc5ef7367fbc8fb475580c291c2655e856cb/hw/i2c/aspeed_i2c.c#L450 Andrew From robh at kernel.org Tue Dec 19 20:22:29 2023 From: robh at kernel.org (Rob Herring) Date: Tue, 19 Dec 2023 03:22:29 -0600 Subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <20231219080021.2048889-2-kcfeng0@nuvoton.com> References: <20231219080021.2048889-1-kcfeng0@nuvoton.com> <20231219080021.2048889-2-kcfeng0@nuvoton.com> Message-ID: <170297774900.1297817.5593278746406765111.robh@kernel.org> On Tue, 19 Dec 2023 16:00:20 +0800, baneric926 at gmail.com wrote: > From: Ban Feng > > Adding bindings for the Nuvoton NCT7363Y Fan Controller > > Signed-off-by: Ban Feng > --- > .../bindings/hwmon/nuvoton,nct7363.yaml | 62 +++++++++++++++++++ > MAINTAINERS | 6 ++ > 2 files changed, 68 insertions(+) > create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13): yamllint warnings/errors: dtschema/dtc warnings/errors: /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml: Error in referenced schema matching $id: http://devicetree.org/schemas/hwmon/fan-common.yaml /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.example.dtb: hwmon at 22: fan-0: False schema does not allow {'pwms': [[1, 0, 50000]], 'tach-ch': ['']} from schema $id: http://devicetree.org/schemas/hwmon/nuvoton,nct7363.yaml# /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.example.dtb: hwmon at 22: fan-1: False schema does not allow {'pwms': [[1, 1, 50000]], 'tach-ch': b'\x01'} from schema $id: http://devicetree.org/schemas/hwmon/nuvoton,nct7363.yaml# /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.example.dtb: fan-1: tach-ch: b'\x01' is not of type 'object', 'array', 'boolean', 'null' from schema $id: http://devicetree.org/schemas/dt-core.yaml# doc reference errors (make refcheckdocs): Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml MAINTAINERS: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20231219080021.2048889-2-kcfeng0 at nuvoton.com The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch. If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date: pip3 install dtschema --upgrade Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema. From fancer.lancer at gmail.com Wed Dec 20 02:48:09 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Tue, 19 Dec 2023 18:48:09 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205115234.7ntjvymurot5nnak@skbuf> Message-ID: Hi Vladimir, Russell, Andrew On Wed, Dec 13, 2023 at 06:27:57PM +0300, Serge Semin wrote: > Hi Vladimir, > > On Tue, Dec 05, 2023 at 01:52:34PM +0200, Vladimir Oltean wrote: > > On Tue, Dec 05, 2023 at 01:35:27PM +0300, Serge Semin wrote: > > > If the DW XPCS MDIO devices are either left unmasked for being auto-probed > > > or explicitly registered in the MDIO subsystem by means of the > > > mdiobus_register_board_info() method > > > > > mdiobus_register_board_info() has exactly one caller, and that is > > dsa_loop. I don't understand the relevance of it w.r.t. Synopsys XPCS. > > I'm reading the patches in order from the beginning. > > Well, one user of the DW XPCS driver is updated in this series in the > framework of the patch: > [PATCH net-next 13/16] net: stmmac: intel: Register generic MDIO device > https://lore.kernel.org/netdev/20231205103559.9605-14-fancer.lancer at gmail.com/ > > I can convert of them (it's sja1105 and wangxun txgbe) and then just > drop the MDIO-device creation part from xpcs_create_mdiodev(). As I > also described in another emails thread below this patch I used to > think that unmasking non-PHY device is also appropriate to get the > MDIO-device instance. I was wrong in that matter obviously. > > Anyway I just realized that my solution of using > mdiobus_register_board_info() is a bit clumsy. Moreover the patch 13 > (see the link above) shouldn't have the mdio_board_info instance > allocation (it can be defined on stack) and most importantly is wrong > in using the device-managed resources for it. The problem is that > mdiobus_register_board_info() registers an MDIO-device once for entire > system lifetime. It isn't that suitable for the hot-swappable devices > and for drivers bind/unbind cases. Since there is no > mdio_board_info-deregistration method, at the simplest case the no > longer used board-info descriptors might be left registered if a > device or driver are unloaded. That's why the device-managed > allocation is harmful in such scenario. At the very least I'll need to > convert the allocations to being non-managed. > > > > > > there is no point in creating the dummy MDIO device instance in order > > > > > Why dummy? There's nothing dummy about the mdio_device. It's how the PCS > > code accesses the hardware. > > I call it 'dummy' because no actual device is registered (though > 'redundant' or similar definition might sound more appropriate). The > entire structure is used as a communication layer between the XPCS > driver and MDIO device, where the device address is the only info > needed. Basically nothing prevents us from converting the current DW > XPCS driver to using the mdiobus_c45_read()/mdiobus_c45_write() > methods. Though in that case I wouldn't be able to easily add the > fwnode-based MDIO-devices support. > > > > > > to get the DW XPCS handler since the MDIO core subsystem will create > > > the device during the MDIO bus registration procedure. > > > > > It won't, though? Unless someone is using mdiobus_register_board_info() > > possibly, but who does that? > > As I said above I wrongly assumed that unmasking non-PHY device was > ok. But mdiobus_register_board_info() could be used for that as I (a > bit clumsy) demonstrated in the patch 13. > > > > > > All what needs to be done is to just reuse the MDIO-device instance > > > available in the mii_bus.mdio_map array (using some getter for it > > > would look better though). It shall prevent the XPCS devices been > > > accessed over several MDIO-device instances. > > > > > > Note since the MDIO-device instance might be retrieved from the MDIO-bus > > > map array its reference counter shall be increased. If the MDIO-device > > > instance is created in the xpcs_create_mdiodev() method its reference > > > counter will be already increased. So there is no point in toggling the > > > reference counter in the xpcs_create() function. Just drop it from there. > > > > > > Signed-off-by: Serge Semin > > > --- > > > > > Sorry, because the commit log lost me at the "context presentation" stage, > > I failed to understand the "what"s and the "why"s. > > > > Are you basically trying to add xpcs support on top of an mdio_device > > where the mdio_device_create() call was made externally to the xpcs code, > > through mdiobus_register_board_info() and mdiobus_setup_mdiodev_from_board_info()? > > Basically yes, but there is more of it. The main idea is to convert > the XPCS driver to using the already created non-PHY MDIO-devices > instead of manually creating a 'dummy'/'redundant' one. From my point > of view there are several reasons of doing so: > > 1. mdiobus_register_board_info() provides a way to assign the device > platform data to being registered afterwards device. Thus we can pass > some custom data to the XPCS-device driver (whether it's just an > xpcs_create_*() call or a fully functional MDIO-device driver > registered by the mdio_driver_register() method). For instance it can > be utilized to drop the fake PHYSIDs implementation from > drivers/net/dsa/sja1105/sja1105_mdio.c . > > 2. The MDIO-devices actually registered on the MDIO-bus will be > visible in sysfs with for instance useful IO statistics provided by > the MDIO-bus. Potentially (if it is required) at some point we'll be > able to convert the DW XPCS driver to being true MDIO-device driver > (bindable to the DW XPCS device) with less efforts. > > 3. Having an MDIO-device registered that way would make the DW XPCS > IO-device implementation unified after the fwnode-based XPCS > descriptor creation support is added in one of the subsequent patches. > > So based on the listed above I've got a question. Do you think all of > that is worth to be implemented? Andrew, Russell? > > I am asking because the patchset advance depends on your answers. If > you do I'll need to fix the problem described in my first message, > implement some new mdiobus_register_board_info()-like but > MDIO-bus-specific interface function (so MDIO-device infos would be > attached to the allocated MDIO-bus and then used to register the > respective MDIO-devices on the MDIO-bus registration), then convert > the sja1105 and wangxun txgbe drivers to using it. If you don't I'll > get back the xpcs_create_mdiodev() implementation and just provide a > fwnode-based version of one. Folks, this is the only issue left to settle so I could move on with the series fixing up. So the question is: taking my comment above into account is it worth to convert the xpcs_create_mdiodev() method to re-using the already registered MDIO-device instance instead of always creating a stub-like MDIO-device? -Serge(y) > > Note we already settled that converting DW XPCS driver to being normal > MDIO-device driver is prone to errors at this stage due to a > possibility to have the driver unbindable from user-space. I'll just > move the DT-compatibles check to the xpcs_create_fwnode() method and > drop the rest of the MDIO-device-driver-specific things. > > -Serge(y) From olteanv at gmail.com Wed Dec 20 03:28:03 2023 From: olteanv at gmail.com (Vladimir Oltean) Date: Tue, 19 Dec 2023 18:28:03 +0200 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205115234.7ntjvymurot5nnak@skbuf> Message-ID: <20231219162803.kmb3jb6aevef3kj3@skbuf> On Tue, Dec 19, 2023 at 06:48:09PM +0300, Serge Semin wrote: > > > Sorry, because the commit log lost me at the "context presentation" stage, > > > I failed to understand the "what"s and the "why"s. > > > > > > Are you basically trying to add xpcs support on top of an mdio_device > > > where the mdio_device_create() call was made externally to the xpcs code, > > > through mdiobus_register_board_info() and mdiobus_setup_mdiodev_from_board_info()? > > > > Basically yes, but there is more of it. The main idea is to convert > > the XPCS driver to using the already created non-PHY MDIO-devices > > instead of manually creating a 'dummy'/'redundant' one. From my point > > of view there are several reasons of doing so: > > > > 1. mdiobus_register_board_info() provides a way to assign the device > > platform data to being registered afterwards device. Thus we can pass > > some custom data to the XPCS-device driver (whether it's just an > > xpcs_create_*() call or a fully functional MDIO-device driver > > registered by the mdio_driver_register() method). For instance it can > > be utilized to drop the fake PHYSIDs implementation from > > drivers/net/dsa/sja1105/sja1105_mdio.c . Ok. Seeing an alternative to the NXP_SJA1110_XPCS_ID hack will be interesting. FWIW, I'm looking at reworking the dsa_loop probing to use software nodes. Since dsa_loop is the only current user of mdiobus_register_board_info(), maybe that will lead to its deletion. It appears a matter of timing, but the mechanism looks promising. Maybe we can also use it somehow to add compatibility with existing lynx-pcs device trees where there is no compatible string, so a struct phy_device gets created. Device tree breakage was the fundamental reason why Sean Anderson's patch set couldn't make forward progress. https://patchwork.kernel.org/project/netdevbpf/cover/20221103210650.2325784-1-sean.anderson at seco.com/ > > 2. The MDIO-devices actually registered on the MDIO-bus will be > > visible in sysfs with for instance useful IO statistics provided by > > the MDIO-bus. Potentially (if it is required) at some point we'll be > > able to convert the DW XPCS driver to being true MDIO-device driver > > (bindable to the DW XPCS device) with less efforts. Ok. > > 3. Having an MDIO-device registered that way would make the DW XPCS > > IO-device implementation unified after the fwnode-based XPCS > > descriptor creation support is added in one of the subsequent patches. Unified how? You mean that "XPCS will always operate as a driver bound to an mdio_device"? You're not planning to unify the mdio_device and MMIO register handling by using regmap, right? > > So based on the listed above I've got a question. Do you think all of > > that is worth to be implemented? Andrew, Russell? > > > > I am asking because the patchset advance depends on your answers. If > > you do I'll need to fix the problem described in my first message, > > implement some new mdiobus_register_board_info()-like but > > MDIO-bus-specific interface function (so MDIO-device infos would be > > attached to the allocated MDIO-bus and then used to register the > > respective MDIO-devices on the MDIO-bus registration), then convert > > the sja1105 and wangxun txgbe drivers to using it. If you don't I'll > > get back the xpcs_create_mdiodev() implementation and just provide a > > fwnode-based version of one. > > Folks, this is the only issue left to settle so I could move on with > the series fixing up. So the question is: taking my comment above into > account is it worth to convert the xpcs_create_mdiodev() method to > re-using the already registered MDIO-device instance instead of > always creating a stub-like MDIO-device? I can't exactly say "yes, this is worth it", because it also depends on what the phylib/phylink maintainers say. So I haven't said anything. But I also don't have any objection, as long as the conversion doesn't break existing setups (in new ways; see the "unbind MDIO bus driver" case which is already problematic). From lkp at intel.com Wed Dec 20 07:25:17 2023 From: lkp at intel.com (kernel test robot) Date: Wed, 20 Dec 2023 04:25:17 +0800 Subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <20231219080021.2048889-2-kcfeng0@nuvoton.com> References: <20231219080021.2048889-2-kcfeng0@nuvoton.com> Message-ID: <202312200427.FGvpu8DB-lkp@intel.com> Hi, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.7-rc6 next-20231219] [cannot apply to groeck-staging/hwmon-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/baneric926-gmail-com/dt-bindings-hwmon-Add-NCT7363Y-documentation/20231219-160534 base: linus/master patch link: https://lore.kernel.org/r/20231219080021.2048889-2-kcfeng0%40nuvoton.com patch subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation reproduce: (https://download.01.org/0day-ci/archive/20231220/202312200427.FGvpu8DB-lkp at intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202312200427.FGvpu8DB-lkp at intel.com/ All warnings (new ones prefixed by >>): >> Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From wsa at kernel.org Wed Dec 20 07:55:58 2023 From: wsa at kernel.org (Wolfram Sang) Date: Tue, 19 Dec 2023 21:55:58 +0100 Subject: [PATCH v4 1/2] i2c: aspeed: Handle the coalesced stop conditions with the start conditions. In-Reply-To: <20231211102217.2436294-2-quan@os.amperecomputing.com> References: <20231211102217.2436294-1-quan@os.amperecomputing.com> <20231211102217.2436294-2-quan@os.amperecomputing.com> Message-ID: On Mon, Dec 11, 2023 at 05:22:16PM +0700, Quan Nguyen wrote: > Some masters may drive the transfers with low enough latency between > the nak/stop phase of the current command and the start/address phase > of the following command that the interrupts are coalesced by the > time we process them. > Handle the stop conditions before processing SLAVE_MATCH to fix the > complaints that sometimes occur below. > > "aspeed-i2c-bus 1e78a040.i2c-bus: irq handled != irq. Expected > 0x00000086, but was 0x00000084" > > Fixes: f9eb91350bb2 ("i2c: aspeed: added slave support for Aspeed I2C driver") > Signed-off-by: Quan Nguyen > Reviewed-by: Andrew Jeffery > Reviewed-by: Andi Shyti Applied to for-current, thanks! I'll wait with patch 2. It seems there are issues to be solved before. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From fancer.lancer at gmail.com Wed Dec 20 08:48:14 2023 From: fancer.lancer at gmail.com (Serge Semin) Date: Wed, 20 Dec 2023 00:48:14 +0300 Subject: [PATCH net-next 06/16] net: pcs: xpcs: Avoid creating dummy XPCS MDIO device In-Reply-To: <20231219162803.kmb3jb6aevef3kj3@skbuf> References: <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-1-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205103559.9605-7-fancer.lancer@gmail.com> <20231205115234.7ntjvymurot5nnak@skbuf> <20231219162803.kmb3jb6aevef3kj3@skbuf> Message-ID: <2jlqxp3jyjautzpf2hn7jeys4omkcntcrx6prjyaativsuqam6@f4szkixopvek> On Tue, Dec 19, 2023 at 06:28:03PM +0200, Vladimir Oltean wrote: > On Tue, Dec 19, 2023 at 06:48:09PM +0300, Serge Semin wrote: > > > > Sorry, because the commit log lost me at the "context presentation" stage, > > > > I failed to understand the "what"s and the "why"s. > > > > > > > > Are you basically trying to add xpcs support on top of an mdio_device > > > > where the mdio_device_create() call was made externally to the xpcs code, > > > > through mdiobus_register_board_info() and mdiobus_setup_mdiodev_from_board_info()? > > > > > > Basically yes, but there is more of it. The main idea is to convert > > > the XPCS driver to using the already created non-PHY MDIO-devices > > > instead of manually creating a 'dummy'/'redundant' one. From my point > > > of view there are several reasons of doing so: > > > > > > 1. mdiobus_register_board_info() provides a way to assign the device > > > platform data to being registered afterwards device. Thus we can pass > > > some custom data to the XPCS-device driver (whether it's just an > > > xpcs_create_*() call or a fully functional MDIO-device driver > > > registered by the mdio_driver_register() method). For instance it can > > > be utilized to drop the fake PHYSIDs implementation from > > > drivers/net/dsa/sja1105/sja1105_mdio.c . > > Ok. Seeing an alternative to the NXP_SJA1110_XPCS_ID hack will be interesting. > > FWIW, I'm looking at reworking the dsa_loop probing to use software nodes. > Since dsa_loop is the only current user of mdiobus_register_board_info(), > maybe that will lead to its deletion. It appears a matter of timing, but > the mechanism looks promising. I think I'll be able to fix my series within two weeks. Seeing it's going to be merge window soon and Xmas/NY holidays then, the patchset will be re-submitted afterwards. Note in my case mdiobus_register_board_info() isn't that well suitable. As I explained a bit earlier in this thread, mdiobus_register_board_info() isn't working for the hot-pluggable devices and for the case when MAC/MDIO-bus drivers unbinding is possible. What could be better is to have a method like this: mdiobus_register_bus_info(struct mii_bus *bus, struct mdio_board_info *info, unsigned int n) { // Add devs-info's into the internal mii_bus-instance list // for each of which the MDIO-devices will be then created and // registered by means of the method // mdiobus_setup_mdiodev_from_board_info() called in // __mdiobus_register(). } Which could be called for the just allocated and not yet registered MDIO-bus descriptor in order to prescribe the non-PHY devices on the bus. Alternatively, what might be even more preferable and easier to implement I could: 1. Globalise and export mdiobus_create_device(). 2. Make sure all non-PHY MDIO-devices are masked in mii_bus instance. 3. Register MDIO-bus. 4. Call mdiobus_create_device() for each XPCS device. 5. Then call xpcs_create_mdiodev() for each registered device. > > Maybe we can also use it somehow to add compatibility with existing > lynx-pcs device trees where there is no compatible string, so a struct > phy_device gets created. Device tree breakage was the fundamental reason > why Sean Anderson's patch set couldn't make forward progress. > https://patchwork.kernel.org/project/netdevbpf/cover/20221103210650.2325784-1-sean.anderson at seco.com/ In case of DW XPCS the solutions described in my comment above are only required for the runtime-registered non-OF MDIO-buses. DW XPCS DT-based devices are unsupported by the current STMMAC driver (adding that support is the main goal of this patchset). So my case is simpler. But regarding your proposal, I guess the first version of the solutions described in my comment above could be suitable for you if the _of_mdiobus_register() method is somehow fixed to considering the DT-nodes with no compatible strings as non-PHY MDIO-devices. For instance the _of_mdiobus_register() function can work that way if it detects some pre-registered mdio_board_info data in the being registered mii_bus instance. Alternatively you could introduce an additional mii_bus structure field which would indicate such non-PHY MDIO-devices. Note in order to make things backward compatible you would need to tweak the drivers/net/ethernet/freescale/xgmac_mdio.c driver so one would detect the platforms (for instance, based on the platform compatible string) on which the Lynx PCSs are specified with no compatible strings and activate the mechanism above. Then you can freely convert the currently available Lynx PCS dts nodes to having the compatible strings. The kernel will be still backwards compatible for old dtbs and will contain the Lynx PCS DT-nodes identified by the proper compatible strings. > > > > 2. The MDIO-devices actually registered on the MDIO-bus will be > > > visible in sysfs with for instance useful IO statistics provided by > > > the MDIO-bus. Potentially (if it is required) at some point we'll be > > > able to convert the DW XPCS driver to being true MDIO-device driver > > > (bindable to the DW XPCS device) with less efforts. > > Ok. > > > > 3. Having an MDIO-device registered that way would make the DW XPCS > > > IO-device implementation unified after the fwnode-based XPCS > > > descriptor creation support is added in one of the subsequent patches. > > Unified how? You mean that "XPCS will always operate as a driver bound > to an mdio_device"? No. I meant that mdio_device would be registered as a normal device on the MDIO-bus in both fwnode-based and runtime-based cases. No driver will be bound to those devices, but some platform-data could be specified and handled identically in both cases. Eventually when the net core is ready for it, the DW XPCS driver could be easily converted to being normal MDIO-device driver and bound to the XPCS devices registered on a MDIO-bus. > > You're not planning to unify the mdio_device and MMIO register handling > by using regmap, right? No. It will be too tiresome especially seeing the current devm_mdio_regmap() implementation doesn't support C45 IO ops and using regmaps would cause having redundant abstraction layers. I see no much benefits in that at the moment. In more details I explained it here: https://lore.kernel.org/netdev/cv6oo27tqbfst3jrgtkg7bcxmeshadtzoomn2xgnzh2arz4nwy at wq5k7oygto6n/ > > > > So based on the listed above I've got a question. Do you think all of > > > that is worth to be implemented? Andrew, Russell? > > > > > > I am asking because the patchset advance depends on your answers. If > > > you do I'll need to fix the problem described in my first message, > > > implement some new mdiobus_register_board_info()-like but > > > MDIO-bus-specific interface function (so MDIO-device infos would be > > > attached to the allocated MDIO-bus and then used to register the > > > respective MDIO-devices on the MDIO-bus registration), then convert > > > the sja1105 and wangxun txgbe drivers to using it. If you don't I'll > > > get back the xpcs_create_mdiodev() implementation and just provide a > > > fwnode-based version of one. > > > > Folks, this is the only issue left to settle so I could move on with > > the series fixing up. So the question is: taking my comment above into > > account is it worth to convert the xpcs_create_mdiodev() method to > > re-using the already registered MDIO-device instance instead of > > always creating a stub-like MDIO-device? > > I can't exactly say "yes, this is worth it", because it also depends on > what the phylib/phylink maintainers say. So I haven't said anything. > But I also don't have any objection, as long as the conversion doesn't > break existing setups (in new ways; see the "unbind MDIO bus driver" > case which is already problematic). Ok. Thanks. There won't be MDIO-device driver binding. I get to decide later what solution described in my first comment to implement (unless you insist on some of them particularly or suggest an alternative). -Serge(y) From baneric926 at gmail.com Tue Dec 19 19:00:19 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Tue, 19 Dec 2023 16:00:19 +0800 Subject: [PATCH v2 0/2] hwmon: Driver for Nuvoton NCT7363Y Message-ID: <20231219080021.2048889-1-kcfeng0@nuvoton.com> From: Ban Feng NCT7363Y is an I2C based hardware monitoring chip from Nuvoton. Changes since version 1: - Modify NCT736X(nct736x) to NCT7363Y(nct7363) - Convert to devm_hwmon_device_register_with_info API - All ID tables are next to each other and should be consistent between i2c_device_id and of_device_id - Ref. fan-common.yaml and modify properties (nuvoton,pwm-mask/ nuvoton,fanin-mask) to (pwms/tach-ch) - Convert to devm_regmap_init_i2c API - Remove unused function (watchdog timer) - Fix uninitialized symbol which is reported by kernel test robot Ban Feng (2): dt-bindings: hwmon: Add NCT7363Y documentation hwmon: Driver for Nuvoton NCT7363Y .../bindings/hwmon/nuvoton,nct7363.yaml | 62 +++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/nct7363.rst | 33 ++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/nct7363.c | 515 ++++++++++++++++++ 7 files changed, 631 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml create mode 100644 Documentation/hwmon/nct7363.rst create mode 100644 drivers/hwmon/nct7363.c -- 2.34.1 From baneric926 at gmail.com Tue Dec 19 19:00:20 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Tue, 19 Dec 2023 16:00:20 +0800 Subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <20231219080021.2048889-1-kcfeng0@nuvoton.com> References: <20231219080021.2048889-1-kcfeng0@nuvoton.com> Message-ID: <20231219080021.2048889-2-kcfeng0@nuvoton.com> From: Ban Feng Adding bindings for the Nuvoton NCT7363Y Fan Controller Signed-off-by: Ban Feng --- .../bindings/hwmon/nuvoton,nct7363.yaml | 62 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml diff --git a/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml new file mode 100644 index 000000000000..8928e0757f24 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/nuvoton,nct7363.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton NCT7363Y Hardware Monitoring IC + +maintainers: + - Ban Feng + +description: | + The NCT7363Y is a Fan controller which provides up to 16 independent + FAN input monitors, and up to 16 independent PWM output with SMBus interface. + +properties: + compatible: + enum: + - nuvoton,nct7363 + + reg: + maxItems: 1 + + "#pwm-cells": + const: 2 + +patternProperties: + "^fan-[0-9]+$": + $ref: fan-common.yaml# + required: + - pwms + - tach-ch + +required: + - compatible + - reg + - "#pwm-cells" + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + hwmon: hwmon at 22 { + compatible = "nuvoton,nct7363"; + reg = <0x22>; + #pwm-cells = <2>; + + fan-0 { + pwms = <&hwmon 0 50000>; + tach-ch = /bits/ 8 <0x00>; + }; + fan-1 { + pwms = <&hwmon 1 50000>; + tach-ch = /bits/ 8 <0x01>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 9104430e148e..c4081a45445e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14838,6 +14838,12 @@ S: Maintained F: Documentation/devicetree/bindings/hwmon/nuvoton,nct6775.yaml F: drivers/hwmon/nct6775-i2c.c +NCT736X HARDWARE MONITOR DRIVER +M: Ban Feng +L: linux-hwmon at vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml + NETDEVSIM M: Jakub Kicinski S: Maintained -- 2.34.1 From baneric926 at gmail.com Tue Dec 19 19:00:21 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Tue, 19 Dec 2023 16:00:21 +0800 Subject: [PATCH v2 2/2] hwmon: Driver for Nuvoton NCT7363Y In-Reply-To: <20231219080021.2048889-1-kcfeng0@nuvoton.com> References: <20231219080021.2048889-1-kcfeng0@nuvoton.com> Message-ID: <20231219080021.2048889-3-kcfeng0@nuvoton.com> From: Ban Feng NCT7363Y is an I2C based hardware monitoring chip from Nuvoton. Signed-off-by: Ban Feng --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/nct7363.rst | 33 ++ MAINTAINERS | 2 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/nct7363.c | 515 ++++++++++++++++++++++++++++++++ 6 files changed, 563 insertions(+) create mode 100644 Documentation/hwmon/nct7363.rst create mode 100644 drivers/hwmon/nct7363.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 72f4e6065bae..178d3cae95de 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -161,6 +161,7 @@ Hardware Monitoring Kernel Drivers mp5023 nct6683 nct6775 + nct7363 nct7802 nct7904 npcm750-pwm-fan diff --git a/Documentation/hwmon/nct7363.rst b/Documentation/hwmon/nct7363.rst new file mode 100644 index 000000000000..89699c95aa4b --- /dev/null +++ b/Documentation/hwmon/nct7363.rst @@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver nct7363 +===================== + +Supported chip: + + * Nuvoton NCT7363Y + + Prefix: nct7363 + + Addresses: I2C 0x20, 0x21, 0x22, 0x23 + +Author: Ban Feng + + +Description +----------- + +The NCT7363Y is a Fan controller which provides up to 16 independent +FAN input monitors, and up to 16 independent PWM output with SMBus interface. + + +Sysfs entries +------------- + +Currently, the driver supports the following features: + +======================= ======================================================= +fanX_input provide current fan rotation value in RPM + +pwmX get or set PWM fan control value. +======================= ======================================================= diff --git a/MAINTAINERS b/MAINTAINERS index c4081a45445e..c7f1293d5b3f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14843,6 +14843,8 @@ M: Ban Feng L: linux-hwmon at vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml +F: Documentation/hwmon/nct7363.rst +F: drivers/hwmon/nct7363.c NETDEVSIM M: Jakub Kicinski diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index cf27523eed5a..58a13c393a8e 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1605,6 +1605,17 @@ config SENSORS_NCT6775_I2C This driver can also be built as a module. If so, the module will be called nct6775-i2c. +config SENSORS_NCT7363 + tristate "Nuvoton NCT7363Y" + depends on I2C + select REGMAP_I2C + help + If you say yes here you get support for the Nuvoton NCT7363Y, + hardware monitoring chip. + + This driver can also be built as a module. If so, the module + will be called nct736x. + config SENSORS_NCT7802 tristate "Nuvoton NCT7802Y" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index e84bd9685b5c..dd794aa06209 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -166,6 +166,7 @@ obj-$(CONFIG_SENSORS_NCT6775_CORE) += nct6775-core.o nct6775-objs := nct6775-platform.o obj-$(CONFIG_SENSORS_NCT6775) += nct6775.o obj-$(CONFIG_SENSORS_NCT6775_I2C) += nct6775-i2c.o +obj-$(CONFIG_SENSORS_NCT7363) += nct7363.o obj-$(CONFIG_SENSORS_NCT7802) += nct7802.o obj-$(CONFIG_SENSORS_NCT7904) += nct7904.o obj-$(CONFIG_SENSORS_NPCM7XX) += npcm750-pwm-fan.o diff --git a/drivers/hwmon/nct7363.c b/drivers/hwmon/nct7363.c new file mode 100644 index 000000000000..1bf6e83afd7f --- /dev/null +++ b/drivers/hwmon/nct7363.c @@ -0,0 +1,515 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023 Nuvoton Technology corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NCT7363_REG_GPIO_0_3 0x20 +#define NCT7363_REG_GPIO_4_7 0x21 +#define NCT7363_REG_GPIO_10_13 0x22 +#define NCT7363_REG_GPIO_14_17 0x23 +#define NCT7363_REG_PWMEN_0_7 0x38 +#define NCT7363_REG_PWMEN_8_15 0x39 +#define NCT7363_REG_FANINEN_0_7 0x41 +#define NCT7363_REG_FANINEN_8_15 0x42 +#define NCT7363_REG_FANINx_HVAL(x) (0x48 + ((x) * 2)) +#define NCT7363_REG_FANINx_LVAL(x) (0x49 + ((x) * 2)) +#define NCT7363_REG_FSCPxDUTY(x) (0x90 + ((x) * 2)) +#define NCT7363_REG_VENDOR_ID 0xFD +#define NCT7363_REG_CHIP_ID 0xFE +#define NCT7363_REG_DEVICE_ID 0xFF + +#define NUVOTON_ID 0x49 +#define CHIP_ID 0x19 +#define DEVICE_ID 0x88 + +#define PWM_SEL(x) (BIT(0) << ((x % 4) * 2)) +#define FANIN_SEL(x) (BIT(1) << ((x % 4) * 2)) +#define BIT_CHECK(x) (BIT(0) << x) + +#define NCT7363_FANINx_LVAL_MASK GENMASK(4, 0) +#define NCT7363_FANIN_MASK GENMASK(12, 0) + +#define NCT7363_PWM_COUNT 16 +#define NCT7363_FANIN_COUNT 16 + +#define REFRESH_INTERVAL (2 * HZ) + +static inline unsigned long FAN_FROM_REG(u16 val) +{ + if ((val >= NCT7363_FANIN_MASK) || (val == 0)) + return 0; + + return (1350000UL / val); +} + +static const unsigned short normal_i2c[] = { + 0x20, 0x21, 0x22, 0x23, I2C_CLIENT_END +}; + +enum chips { nct7363 }; + +static const struct i2c_device_id nct7363_id[] = { + { "nct7363", nct7363 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, nct7363_id); + +static const struct of_device_id nct7363_of_match[] = { + { .compatible = "nuvoton,nct7363", .data = (void *)nct7363 }, + { }, +}; +MODULE_DEVICE_TABLE(of, nct7363_of_match); + +struct nct7363_data { + struct regmap *regmap; + struct mutex update_lock; + bool valid; + unsigned long last_updated; /* In jiffies */ + + u16 fanin_mask; + u16 fan[NCT7363_FANIN_COUNT]; + u16 pwm_mask; + u8 pwm[NCT7363_PWM_COUNT]; +}; + +static struct nct7363_data *nct7363_update_device(struct device *dev) +{ + struct nct7363_data *data = dev_get_drvdata(dev); + unsigned int hi, lo, regval; + int i, ret = 0; + + mutex_lock(&data->update_lock); + + if (!(time_after(jiffies, data->last_updated + REFRESH_INTERVAL) + || !data->valid)) + goto no_sensor_update; + + for (i = 0; i < ARRAY_SIZE(data->fan); i++) { + if (!(data->fanin_mask & BIT_CHECK(i))) + continue; + + /* + * High-byte register should be read first to latch + * synchronous low-byte value + */ + ret = regmap_read(data->regmap, + NCT7363_REG_FANINx_HVAL(i), &hi); + if (ret) + goto error; + + ret = regmap_read(data->regmap, + NCT7363_REG_FANINx_LVAL(i), &lo); + if (ret) + goto error; + + data->fan[i] = (hi << 5) | (lo & NCT7363_FANINx_LVAL_MASK); + } + + for (i = 0; i < ARRAY_SIZE(data->pwm); i++) { + if (!(data->pwm_mask & BIT_CHECK(i))) + continue; + + ret = regmap_read(data->regmap, + NCT7363_REG_FSCPxDUTY(i), ®val); + if (ret) + goto error; + + data->pwm[i] = regval; + } + + data->last_updated = jiffies; + data->valid = true; + +error: + if (ret) + data = ERR_PTR(ret); + +no_sensor_update: + mutex_unlock(&data->update_lock); + + return data; +} + +static int nct7363_read_fan(struct device *dev, u32 attr, int channel, + long *val) +{ + struct nct7363_data *data = nct7363_update_device(dev); + u16 cnt, rpm; + + if (IS_ERR(data)) + return PTR_ERR(data); + + switch (attr) { + case hwmon_fan_input: + cnt = data->fan[channel] & NCT7363_FANIN_MASK; + rpm = FAN_FROM_REG(cnt); + *val = (long)rpm; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_fan_is_visible(const void *_data, u32 attr, int channel) +{ + const struct nct7363_data *data = _data; + + switch (attr) { + case hwmon_fan_input: + if (data->fanin_mask & BIT_CHECK(channel)) + return 0444; + break; + default: + break; + } + + return 0; +} + +static int nct7363_read_pwm(struct device *dev, u32 attr, int channel, + long *val) +{ + struct nct7363_data *data = nct7363_update_device(dev); + u16 ret; + + if (IS_ERR(data)) + return PTR_ERR(data); + + switch (attr) { + case hwmon_pwm_input: + ret = data->pwm[channel]; + *val = (long)ret; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int nct7363_write_pwm(struct device *dev, u32 attr, int channel, + long val) +{ + struct nct7363_data *data = nct7363_update_device(dev); + int ret; + + if (IS_ERR(data)) + return PTR_ERR(data); + + switch (attr) { + case hwmon_pwm_input: + if (val < 0 || val > 255) + return -EINVAL; + mutex_lock(&data->update_lock); + ret = regmap_write(data->regmap, + NCT7363_REG_FSCPxDUTY(channel), val); + if (ret == 0) + data->pwm[channel] = val; + mutex_unlock(&data->update_lock); + return ret; + + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_pwm_is_visible(const void *_data, u32 attr, int channel) +{ + const struct nct7363_data *data = _data; + + switch (attr) { + case hwmon_pwm_input: + if (data->pwm_mask & BIT_CHECK(channel)) + return 0644; + break; + default: + break; + } + + return 0; +} + +static int nct7363_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + switch (type) { + case hwmon_fan: + return nct7363_read_fan(dev, attr, channel, val); + case hwmon_pwm: + return nct7363_read_pwm(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static int nct7363_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + switch (type) { + case hwmon_pwm: + return nct7363_write_pwm(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_is_visible(const void *data, + enum hwmon_sensor_types type, + u32 attr, int channel) +{ + switch (type) { + case hwmon_fan: + return nct7363_fan_is_visible(data, attr, channel); + case hwmon_pwm: + return nct7363_pwm_is_visible(data, attr, channel); + default: + return 0; + } +} + +static const struct hwmon_channel_info *nct7363_info[] = { + HWMON_CHANNEL_INFO(fan, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT), + NULL +}; + +static const struct hwmon_ops nct7363_hwmon_ops = { + .is_visible = nct7363_is_visible, + .read = nct7363_read, + .write = nct7363_write, +}; + +static const struct hwmon_chip_info nct7363_chip_info = { + .ops = &nct7363_hwmon_ops, + .info = nct7363_info, +}; + +/* Return 0 if detection is successful, -ENODEV otherwise */ +static int nct7363_detect(struct i2c_client *client, + struct i2c_board_info *info) +{ + struct i2c_adapter *adapter = client->adapter; + int vendor, chip, device; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + return -ENODEV; + + vendor = i2c_smbus_read_byte_data(client, NCT7363_REG_VENDOR_ID); + if (vendor != NUVOTON_ID) + return -ENODEV; + + chip = i2c_smbus_read_byte_data(client, NCT7363_REG_CHIP_ID); + if (chip != CHIP_ID) + return -ENODEV; + + device = i2c_smbus_read_byte_data(client, NCT7363_REG_DEVICE_ID); + if (device != DEVICE_ID) + return -ENODEV; + + strscpy(info->type, "nct7363", I2C_NAME_SIZE); + + return 0; +} + +static int nct7363_init_chip(struct nct7363_data *data) +{ + u8 i, gpio0_3 = 0, gpio4_7 = 0, gpio10_13 = 0, gpio14_17 = 0; + int ret; + + for (i = 0; i < NCT7363_PWM_COUNT; i++) { + if (i < 4) { + if (data->pwm_mask & BIT_CHECK(i)) + gpio0_3 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio10_13 |= FANIN_SEL(i); + } else if (i < 8) { + if (data->pwm_mask & BIT_CHECK(i)) + gpio4_7 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio14_17 |= FANIN_SEL(i); + } else if (i < 12) { + if (data->pwm_mask & BIT_CHECK(i)) + gpio10_13 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio0_3 |= FANIN_SEL(i); + } else { + if (data->pwm_mask & BIT_CHECK(i)) + gpio14_17 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio4_7 |= FANIN_SEL(i); + } + } + + /* Pin Function Configuration */ + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_0_3, gpio0_3); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_4_7, gpio4_7); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_10_13, gpio10_13); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_14_17, gpio14_17); + if (ret < 0) + return ret; + + /* PWM and FANIN Monitoring Enable */ + ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_0_7, + data->pwm_mask & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_8_15, + (data->pwm_mask >> 8) & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_0_7, + data->fanin_mask & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_8_15, + (data->fanin_mask >> 8) & 0xff); + if (ret < 0) + return ret; + + return 0; +} + +static int nct7363_present_pwm_fanin(struct device *dev, + struct device_node *child, + struct nct7363_data *data) +{ + struct of_phandle_args args; + int ret, fanin_cnt; + u8 *fanin_ch; + u8 ch, index; + + ret = of_parse_phandle_with_args(child, "pwms", "#pwm-cells", + 0, &args); + if (ret) + return ret; + + data->pwm_mask |= BIT(args.args[0]); + + fanin_cnt = of_property_count_u8_elems(child, "tach-ch"); + if (fanin_cnt < 1) + return -EINVAL; + + fanin_ch = devm_kcalloc(dev, fanin_cnt, sizeof(*fanin_ch), GFP_KERNEL); + if (!fanin_ch) + return -ENOMEM; + + ret = of_property_read_u8_array(child, "tach-ch", fanin_ch, fanin_cnt); + if (ret) + return ret; + + for (ch = 0; ch < fanin_cnt; ch++) { + index = fanin_ch[ch]; + data->fanin_mask |= BIT(index); + } + + return 0; +} + +static const struct regmap_config nct7363_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int nct7363_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct device_node *child; + struct nct7363_data *data; + struct device *hwmon_dev; + int ret; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->regmap = devm_regmap_init_i2c(client, &nct7363_regmap_config); + if (IS_ERR(data->regmap)) + return PTR_ERR(data->regmap); + + mutex_init(&data->update_lock); + + for_each_child_of_node(dev->of_node, child) { + ret = nct7363_present_pwm_fanin(dev, child, data); + if (ret) { + of_node_put(child); + return ret; + } + } + + /* Initialize the chip */ + ret = nct7363_init_chip(data); + if (ret) + return ret; + + hwmon_dev = + devm_hwmon_device_register_with_info(dev, client->name, data, + &nct7363_chip_info, NULL); + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static struct i2c_driver nct7363_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "nct7363", + .of_match_table = nct7363_of_match, + }, + .probe = nct7363_probe, + .id_table = nct7363_id, + .detect = nct7363_detect, + .address_list = normal_i2c, +}; + +module_i2c_driver(nct7363_driver); + +MODULE_AUTHOR("CW Ho "); +MODULE_AUTHOR("Ban Feng "); +MODULE_DESCRIPTION("NCT7363 Hardware Monitoring Driver"); +MODULE_LICENSE("GPL"); -- 2.34.1 From liuxiwei1013 at gmail.com Wed Dec 20 20:38:39 2023 From: liuxiwei1013 at gmail.com (George Liu) Date: Wed, 20 Dec 2023 17:38:39 +0800 Subject: [PATCH v1 1/2] ARM: dts: aspeed: Add IEISystems FP5280G3 BMC machine Message-ID: <20231220093839.2032368-1-liuxiwei@ieisystem.com> The IEISystems FP5280G3 is a power platform server with an AST2600-based BMC. This dts file provides a basic configuration for its OpenBMC development. Signed-off-by: George Liu --- v1 1/1 -> v1 1/2 - include ibm-power10-quad.dtsi - Remove redundant blank lines - Remove nct7362 driver - Remove bus-timeout-ms & bus-recover-timeout-ms - Remove reset-mask1 --- arch/arm/boot/dts/aspeed/Makefile | 1 + .../aspeed/aspeed-bmc-ieisystems-fp5280g3.dts | 966 ++++++++++++++++++ 2 files changed, 967 insertions(+) create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts diff --git a/arch/arm/boot/dts/aspeed/Makefile b/arch/arm/boot/dts/aspeed/Makefile index fb9cc95f1b60..6017ff5b7959 100644 --- a/arch/arm/boot/dts/aspeed/Makefile +++ b/arch/arm/boot/dts/aspeed/Makefile @@ -36,6 +36,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += \ aspeed-bmc-ibm-rainier.dtb \ aspeed-bmc-ibm-rainier-1s4u.dtb \ aspeed-bmc-ibm-rainier-4u.dtb \ + aspeed-bmc-ieisystems-fp5280g3.dtb \ aspeed-bmc-intel-s2600wf.dtb \ aspeed-bmc-inspur-fp5280g2.dtb \ aspeed-bmc-inspur-nf5280m6.dtb \ diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts new file mode 100644 index 000000000000..51f0c8903b63 --- /dev/null +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts @@ -0,0 +1,966 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2023, IEISystems Corporation + +/dts-v1/; + +#include "aspeed-g6.dtsi" +#include +#include + +/ { + model = "FP5280G3 BMC"; + compatible = "ieisystems,fp5280g3-bmc", "aspeed,ast2600"; + + aliases { + i2c2001 = &i2c2s0ch1; + i2c2002 = &i2c2s0ch2; + i2c5000 = &i2c5s0ch0; + i2c5001 = &i2c5s0ch1; + i2c5002 = &i2c5s0ch2; + i2c5003 = &i2c5s0ch3; + i2c6000 = &i2c6s0ch0; + i2c6001 = &i2c6s0ch1; + i2c6002 = &i2c6s0ch2; + i2c6003 = &i2c6s0ch3; + i2c6004 = &i2c6s0ch4; + i2c6005 = &i2c6s0ch5; + i2c6100 = &i2c6s1ch0; + i2c6101 = &i2c6s1ch1; + i2c6200 = &i2c6s2ch0; + i2c6201 = &i2c6s2ch1; + i2c12000 = &i2c12s0ch0; + i2c12001 = &i2c12s0ch1; + i2c12002 = &i2c12s0ch2; + i2c12003 = &i2c12s0ch3; + i2c12100 = &i2c12s1ch0; + i2c12101 = &i2c12s1ch1; + i2c12102 = &i2c12s1ch2; + i2c13000 = &i2c13s0ch0; + i2c13001 = &i2c13s0ch1; + i2c13002 = &i2c13s0ch2; + i2c13003 = &i2c13s0ch3; + }; + + chosen { + stdout-path = &uart5; + bootargs = "console=ttyS4,115200n8 earlycon"; + }; + + memory at 80000000 { + device_type = "memory"; + reg = <0x80000000 0x80000000>; + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + ramoops at b3e00000 { + compatible = "ramoops"; + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ + record-size = <0x8000>; + console-size = <0x8000>; + ftrace-size = <0x8000>; + pmsg-size = <0x8000>; + max-reason = <3>; /* KMSG_DUMP_EMERG */ + }; + + /* LPC FW cycle bridge region requires natural alignment */ + flash_memory: region at b4000000 { + no-map; + reg = <0xb4000000 0x04000000>; /* 64M */ + }; + + /* VGA region is dictated by hardware strapping */ + vga_memory: region at bf000000 { + no-map; + compatible = "shared-dma-pool"; + reg = <0xbf000000 0x01000000>; /* 16M */ + }; + + video_engine_memory: jpegbuffer { + size = <0x02000000>; /* 32M */ + alignment = <0x01000000>; + compatible = "shared-dma-pool"; + reusable; + }; + gfx_memory: framebuffer { + size = <0x01000000>; + alignment = <0x01000000>; + compatible = "shared-dma-pool"; + reusable; + }; + }; + + iio-hwmon { + compatible = "iio-hwmon"; + io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, + <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, + <&adc0 7>, <&adc1 0>; + }; + + gpio-keys { + compatible = "gpio-keys"; + + cpld { + label = "cpld"; + gpios = <&gpio0 ASPEED_GPIO(S, 4) GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + bmc-heart-beat { + gpios = <&gpio0 ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + bmc-init-ok { + gpios = <&gpio0 ASPEED_GPIO(R, 5) GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + chassis-power-on { + gpios = <&gpio0 ASPEED_GPIO(Q, 3) GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + bmc-bootup { + gpios = <&gpio0 ASPEED_GPIO(S, 0) GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + fan-watchdog { + label = "fan-watchdog"; + gpios = <&gpio0 ASPEED_GPIO(E, 0) GPIO_ACTIVE_LOW>; + linux,default-trigger = "timer"; + }; + }; + +}; + +&adc0 { + status = "okay"; + aspeed,int-vref-microvolt = <2500000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc0_default + &pinctrl_adc1_default + &pinctrl_adc2_default + &pinctrl_adc3_default + &pinctrl_adc4_default + &pinctrl_adc5_default + &pinctrl_adc6_default + &pinctrl_adc7_default>; +}; + +&adc1 { + status = "okay"; + aspeed,int-vref-microvolt = <2500000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc8_default>; +}; + +&gpio0 { + gpio-line-names = + /*A0-A7*/ "","","","","","","","", + /*B0-B7*/ "","","","","","","","", + /*C0-C7*/ "","","","","","","","", + /*D0-D7*/ "","","","","","","","", + /*E0-E7*/ "","","","","","","","", + /*F0-F7*/ "","","","","","","","", + /*G0-G7*/ "","","","","","","","", + /*H0-H7*/ "","","","","","","","", + /*I0-I7*/ "","","","","","","","", + /*J0-J7*/ "","","","","","","","", + /*K0-K7*/ "","","","","","","","", + /*L0-L7*/ "","","","","","","","", + /*M0-M7*/ "","","","","","","","", + /*N0-N7*/ "","","","","SCM_CPLD_UPDATE_HITLESS","","","", + /*O0-O7*/ "","","","","","","","", + /*P0-P7*/ "","","","","","","","", + /*Q0-Q7*/ "","","","","","FM_PSU1_PRSNT_N","FM_PSU0_PRSNT_N","MB_CPLD_UPDATE_HITLESS", + /*R0-R7*/ "","","","checkstop","","","power-chassis-control","power-button", + /*S0-S7*/ "","","POSTFINISH","","","FM_BATTERY_SENSE_EN","","", + /*T0-T7*/ "","","","","","","","", + /*U0-U7*/ "","","","","","","","", + /*V0-V7*/ "","","","","power-chassis-good","","","", + /*W0-W7*/ "","","","","","","","", + /*X0-X7*/ "","","","","","","","", + /*Y0-Y7*/ "","","","","","","","", + /*Z0-Z7*/ "","","","","","","",""; +}; + +&mdio1 { + status = "okay"; + + ethphy1: ethernet-phy at 0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; +}; + +&mac2 { + status = "okay"; + + phy-mode = "rgmii"; + phy-handle = <ðphy1>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rgmii3_default>; +}; + +&mac3 { + status = "okay"; + + phy-mode = "rmii"; + use-ncsi; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rmii4_default>; +}; + +&emmc_controller { + status = "okay"; +}; + +&pinctrl_emmc_default { + bias-disable; +}; + +&emmc { + status = "okay"; + clk-phase-mmc-hs200 = <180>, <180>; +}; + +#include "ibm-power10-quad.dtsi" +&fsim0 { + cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 4) GPIO_ACTIVE_LOW>; +}; + +&i2c1 { + status = "okay"; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "Sys_Outlet_Temp"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; +}; + +&i2c2 { + status = "okay"; + tmp112 at 40{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "Inlet_Temp"; + }; + + pca9548 at 70{ + compatible = "nxp,pca9548"; + reg = <0x70>; + i2c2s0ch1: i2c at 1{ + reg = <1>; + tmp112 at 49{ + compatible = "ti,tmp112"; + reg = <0x49>; + label = "PSU_Inlet0_Temp"; + }; + tmp112 at 4a{ + compatible = "ti,tmp112"; + reg = <0x4a>; + label = "PSU_Inlet1_Temp"; + }; + }; + i2c2s0ch2: i2c at 2{ + reg = <2>; + tmp112 at 49{ + compatible = "ti,tmp112"; + reg = <0x49>; + label = "L_OCP_ZONE_Temp"; + }; + tmp112 at 4a{ + compatible = "ti,tmp112"; + reg = <0x4a>; + label = "R_OCP_ZONE_Temp"; + }; + }; + }; + + pca0:pca9555 at 20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "OCP0_CABLE_PRSNT_N", "OCP0_BIF2_N", + "OCP0_BIF1_N", "OCP0_BIF0_N", + "OCP0_CARD_PRSNTB3_ISO_N", "OCP0_CARD_PRSNTB2_ISO_N", + "OCP0_CARD_PRSNTB1_ISO_N", "OCP0_CARD_PRSNTB0_ISO_N", + "PE_MCIO0_BP_ID0_Q_N", "PE_MCIO0_BP_ID1_Q_N", + "PE_MCIO1_BP_ID0_Q_N", "PE_MCIO1_BP_ID1_Q_N", + "PE_MCIO2_BP_ID0_Q_N", "PE_MCIO2_BP_ID1_Q_N", + "RISER0_PRSNT_N", "REAR_HDD_PRSNT_N"; + }; + pca1:pca9555 at 21 { + compatible = "nxp,pca9555"; + reg = <0x21>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "OCP1_CABLE_PRSNT_N", "OCP1_BIF2_N", + "OCP1_BIF1_N", "OCP1_BIF0_N", + "OCP1_CARD_PRSNTB3_ISO_N", "OCP1_CARD_PRSNTB2_ISO_N", + "OCP1_CARD_PRSNTB1_ISO_N", "OCP1_CARD_PRSNTB0_ISO_N", + "PE_MCIO3_BP_ID0_Q_N", "PE_MCIO3_BP_ID1_Q_N", + "PE_MCIO4_BP_ID0_Q_N", "PE_MCIO4_BP_ID1_Q_N", + "PE_MCIO5_BP_ID0_Q_N", "PE_MCIO5_BP_ID1_Q_N", + "RISER2_PRSNT_N", "RISER1_PRSNT_N"; + }; + pca2:pca9555 at 22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER2_BOARD_ID1_N", "RISER2_BOARD_ID0_N", + "RISER1_BOARD_ID2_N", "RISER1_BOARD_ID1_N", + "RISER1_BOARD_ID0_N", "RISER0_BOARD_ID2_N", + "RISER0_BOARD_ID1_N", "RISER0_BOARD_ID0_N", + "PE_MCIO6_BP_ID0_Q_N", "PE_MCIO6_BP_ID1_Q_N", + "PE_MCIO7_BP_ID0_Q_N", "PE_MCIO7_BP_ID1_Q_N", + "PE_MCIO8_BP_ID0_Q_N", "PE_MCIO8_BP_ID1_Q_N", + "PE_MCIO9_BP_ID0_Q_N", "PE_MCIO9_BP_ID0_Q_N"; + }; + pca3:pca9555 at 23 { + compatible = "nxp,pca9555"; + reg = <0x23>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", + "", "", + "", "", + "", "RISER2_BOARD_ID2_N", + "PE_MCIO10_BP_ID0_Q_N", "PE_MCIO10_BP_ID1_Q_N", + "PE_MCIO7_BP_ID11_Q_N", "PE_MCIO11_BP_ID1_Q_N", + "PE_MCIO12_BP_ID0_Q_N", "PE_MCIO12_BP_ID1_Q_N", + "PE_MCIO13_BP_ID0_Q_N", "PE_MCIO13_BP_ID0_Q_N"; + }; +}; + +&i2c3 { + status = "okay"; + pca9548 at 70 { + compatible = "nxp,pca9548"; + reg = <0x70>; + }; +}; + +&i2c5 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c5s0ch0: i2c at 0 { + reg = <0>; + status = "okay"; + cpu0vdda at 60 { + compatible = "infineon,xdpe132g5c"; + reg = <0x60>; + }; + cpu0vddb at 61 { + compatible = "infineon,xdpe132g5c"; + reg = <0x61>; + }; + cpu0vdn at 72 { + compatible = "infineon,ir35221"; + reg = <0x72>; + }; + cpu0vio at 73 { + compatible = "infineon,ir35221"; + reg = <0x73>; + }; + cpu0vpci at 74 { + compatible = "infineon,ir35221"; + reg = <0x74>; + }; + }; + i2c5s0ch1: i2c at 1{ + reg = <1>; + status = "okay"; + cpu1vddc at 60 { + compatible = "infineon,xdpe132g5c"; + reg = <0x60>; + }; + cpu1vddd at 61 { + compatible = "infineon,xdpe132g5c"; + reg = <0x61>; + }; + cpu1vdn at 72 { + compatible = "infineon,ir35221"; + reg = <0x72>; + }; + cpu1vio at 73 { + compatible = "infineon,ir35221"; + reg = <0x73>; + }; + cpu1vpci at 74 { + compatible = "infineon,ir35221"; + reg = <0x74>; + }; + }; + i2c5s0ch2: i2c at 2{ + reg = <2>; + status = "okay"; + pxe1610 at 6c { + compatible = "infineon,pxe1610"; + reg = <0x6c>; + }; + rdimm at 74 { + compatible = "infineon,pxe1610"; + reg = <0x74>; + }; + mdimm at 54 { + compatible = "infineon,pxe1610"; + reg = <0x5A>; + }; + ldimm at 44 { + compatible = "infineon,pxe1610"; + reg = <0x5C>; + }; + }; + i2c5s0ch3: i2c at 3{ + reg = <3>; + }; + }; +}; + +&i2c6 { + /* SMB_TEMPSENSOR_STBY_LVC3_R */ + multi-master; + status = "okay"; + + i2c-switch at 70 { + compatible = "nxp,pca9548"; + reg = <0x70>; + #address-cells = <1>; + #size-cells = <0>; + + i2c6s0ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch2: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch3: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + + pca9548 at 71 { + compatible = "nxp,pca9548"; + reg = <0x71>; + i2c-mux-idle-disconnect; + + i2c6s1ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + i2c6s1ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; + i2c6s0ch4: i2c at 4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + + pca9548 at 71 { + compatible = "nxp,pca9548"; + reg = <0x71>; + i2c-mux-idle-disconnect; + + i2c6s2ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + i2c6s2ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; + i2c6s0ch5: i2c at 5 { + #address-cells = <1>; + #size-cells = <0>; + reg = <5>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + }; +}; + +&i2c7 { + status = "okay"; + adc128d818 at 1d{ + compatible = "ti,adc128d818"; + reg = <0x1d>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 1e{ + compatible = "ti,adc128d818"; + reg = <0x1e>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 1f{ + compatible = "ti,adc128d818"; + reg = <0x1f>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2d{ + compatible = "ti,adc128d818"; + reg = <0x2d>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2e{ + compatible = "ti,adc128d818"; + reg = <0x2e>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2f{ + compatible = "ti,adc128d818"; + reg = <0x2f>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 35{ + compatible = "ti,adc128d818"; + reg = <0x35>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 36{ + compatible = "ti,adc128d818"; + reg = <0x36>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 37{ + compatible = "ti,adc128d818"; + reg = <0x37>; + ti,mode = /bits/ 8 <0x01>; + }; +}; + +&i2c8 { + status = "okay"; + + pca9555 at 24{ + compatible = "nxp,pca9555"; + reg = <0x24>; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "FAN_PRSNT5_D_N", "FAN_PRSNT4_D_N", + "FAN_PRSNT3_D_N", "FAN_PRSNT2_D_N", + "FAN_PRSNT1_D_N", "FAN_PRSNT0_D_N", + "", "", + "", "", "", "", + "", "", "", ""; + }; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; + +}; + +&i2c9 { + status = "okay"; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; +}; + +&i2c10 { + status = "okay"; + pca9555 at 20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "DIMM0_FAULT", "DIMM3_FAULT", + "DIMM2_FAULT", "DIMM1_FAULT", + "DIMM4_FAULT", "DIMM5_FAULT", + "DIMM6_FAULT", "DIMM7_FAULT", + "DIMM8_FAULT", "DIMM11_FAULT", + "DIMM10_FAULT", "DIMM9_FAULT", + "DIMM12_FAULT", "DIMM13_FAULT", + "DIMM14_FAULT", "DIMM15_FAULT"; + }; + + pca9555 at 22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", "", "", "OCP0_PRSNT_N", "", "", "", + "", "", "", "", "", "", "", ""; + }; + + pca9555 at 23 { + compatible = "nxp,pca9555"; + reg = <0x23>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", "", "", "OCP1_PRSNT_N", "", "", "", + "", "", "", "", "", "", "", ""; + }; +}; + +&i2c11 { + status = "okay"; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; +}; + +&i2c12 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c-mux-idle-disconnect; + i2c12s0ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_0"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER0_BOARD_ID7", "RISER0_BOARD_ID6", + "RISER0_BOARD_ID5", "RISER0_BOARD_ID4", + "RISER0_BOARD_ID3", "RISER0_BOARD_ID2", + "RISER0_BOARD_ID1", "RISER0_BOARD_ID0", + "RISER0_SLOT2_PRSNT", "RISER0_SLOT1_PRSNT_X8", + "RISER0_SLOT0_PRSNT_X8", "RISER0_SLOT1_PRSNT_X16", + "RISER0_SLOT0_PRSNT_X16", "", "", ""; + }; + }; + i2c12s0ch1: i2c at 1{ + reg = <1>; + }; + i2c12s0ch2: i2c at 2{ + reg = <2>; + }; + i2c12s0ch3: i2c at 3{ + reg = <3>; + }; + }; + + pca9546 at 71{ + compatible = "nxp,pca9546"; + reg = <0x71>; + i2c-mux-idle-disconnect; + i2c12s1ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_2"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER2_BOARD_ID0", "RISER2_BOARD_ID1", + "RISER2_BOARD_ID2", "RISER2_BOARD_ID3", + "RISER2_BOARD_ID4", "RISER2_BOARD_ID5", + "RISER2_BOARD_ID6", "RISER2_BOARD_ID7", + "RISER2_SLOT0_PRSNT", "RISER2_SLOT1_PRSNT", + "", "", "", "", "", ""; + }; + }; + i2c12s1ch1: i2c at 1{ + reg = <1>; + }; + i2c12s1ch2: i2c at 2{ + reg = <2>; + }; + }; +}; + +&i2c13 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c-mux-idle-disconnect; + i2c13s0ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_1"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER1_BOARD_ID7", "RISER1_BOARD_ID6", + "RISER1_BOARD_ID5", "RISER1_BOARD_ID4", + "RISER1_BOARD_ID3", "RISER1_BOARD_ID2", + "RISER1_BOARD_ID1", "RISER1_BOARD_ID0", + "RISER1_SLOT2_PRSNT", "RISER1_SLOT1_PRSNT_X8", + "RISER1_SLOT0_PRSNT_X8", "RISER1_SLOT1_PRSNT_X16", + "RISER1_SLOT0_PRSNT_X16", "", "", ""; + }; + }; + i2c13s0ch1: i2c at 1{ + reg = <1>; + }; + i2c13s0ch2: i2c at 2{ + reg = <2>; + }; + i2c13s0ch3: i2c at 3{ + reg = <3>; + }; + }; +}; + +&i2c14 { + status = "okay"; +}; + +&i2c15 { + status = "okay"; +}; + +&ibt { + status = "okay"; +}; + +&uart1 { + status = "okay"; +}; + +&vuart1 { + status = "okay"; +}; + +&vuart2 { + status = "okay"; +}; + +&lpc_ctrl { + status = "okay"; + memory-region = <&flash_memory>; +}; + +&wdt1 { + status = "okay"; +}; + +&kcs2 { + status = "okay"; + aspeed,lpc-io-reg = <0xca8 0xcac>; +}; + +&kcs3 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; +}; + +&vhub { + status = "okay"; +}; + +&video { + status = "okay"; + memory-region = <&video_engine_memory>; +}; + +&gfx { + status = "okay"; + memory-region = <&gfx_memory>; +}; -- 2.34.1 From liuxiwei1013 at gmail.com Wed Dec 20 20:50:04 2023 From: liuxiwei1013 at gmail.com (George Liu) Date: Wed, 20 Dec 2023 17:50:04 +0800 Subject: [PATCH v2] ARM: dts: aspeed: Add IEISystems FP5280G3 BMC machine Message-ID: <20231220095004.2036251-1-liuxiwei@ieisystem.com> The IEISystems FP5280G3 is a power platform server with an AST2600-based BMC. This dts file provides a basic configuration for its OpenBMC development. Signed-off-by: George Liu --- v1 -> v2 - Include ibm-power10-quad.dtsi - Remove redundant blank lines - Remove nct7362 driver - Remove bus-timeout-ms & bus-recover-timeout-ms - Remove reset-mask1 --- arch/arm/boot/dts/aspeed/Makefile | 1 + .../aspeed/aspeed-bmc-ieisystems-fp5280g3.dts | 966 ++++++++++++++++++ 2 files changed, 967 insertions(+) create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts diff --git a/arch/arm/boot/dts/aspeed/Makefile b/arch/arm/boot/dts/aspeed/Makefile index fb9cc95f1b60..6017ff5b7959 100644 --- a/arch/arm/boot/dts/aspeed/Makefile +++ b/arch/arm/boot/dts/aspeed/Makefile @@ -36,6 +36,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += \ aspeed-bmc-ibm-rainier.dtb \ aspeed-bmc-ibm-rainier-1s4u.dtb \ aspeed-bmc-ibm-rainier-4u.dtb \ + aspeed-bmc-ieisystems-fp5280g3.dtb \ aspeed-bmc-intel-s2600wf.dtb \ aspeed-bmc-inspur-fp5280g2.dtb \ aspeed-bmc-inspur-nf5280m6.dtb \ diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts new file mode 100644 index 000000000000..51f0c8903b63 --- /dev/null +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts @@ -0,0 +1,966 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2023, IEISystems Corporation + +/dts-v1/; + +#include "aspeed-g6.dtsi" +#include +#include + +/ { + model = "FP5280G3 BMC"; + compatible = "ieisystems,fp5280g3-bmc", "aspeed,ast2600"; + + aliases { + i2c2001 = &i2c2s0ch1; + i2c2002 = &i2c2s0ch2; + i2c5000 = &i2c5s0ch0; + i2c5001 = &i2c5s0ch1; + i2c5002 = &i2c5s0ch2; + i2c5003 = &i2c5s0ch3; + i2c6000 = &i2c6s0ch0; + i2c6001 = &i2c6s0ch1; + i2c6002 = &i2c6s0ch2; + i2c6003 = &i2c6s0ch3; + i2c6004 = &i2c6s0ch4; + i2c6005 = &i2c6s0ch5; + i2c6100 = &i2c6s1ch0; + i2c6101 = &i2c6s1ch1; + i2c6200 = &i2c6s2ch0; + i2c6201 = &i2c6s2ch1; + i2c12000 = &i2c12s0ch0; + i2c12001 = &i2c12s0ch1; + i2c12002 = &i2c12s0ch2; + i2c12003 = &i2c12s0ch3; + i2c12100 = &i2c12s1ch0; + i2c12101 = &i2c12s1ch1; + i2c12102 = &i2c12s1ch2; + i2c13000 = &i2c13s0ch0; + i2c13001 = &i2c13s0ch1; + i2c13002 = &i2c13s0ch2; + i2c13003 = &i2c13s0ch3; + }; + + chosen { + stdout-path = &uart5; + bootargs = "console=ttyS4,115200n8 earlycon"; + }; + + memory at 80000000 { + device_type = "memory"; + reg = <0x80000000 0x80000000>; + }; + + reserved-memory { + #address-cells = <1>; + #size-cells = <1>; + ranges; + + ramoops at b3e00000 { + compatible = "ramoops"; + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ + record-size = <0x8000>; + console-size = <0x8000>; + ftrace-size = <0x8000>; + pmsg-size = <0x8000>; + max-reason = <3>; /* KMSG_DUMP_EMERG */ + }; + + /* LPC FW cycle bridge region requires natural alignment */ + flash_memory: region at b4000000 { + no-map; + reg = <0xb4000000 0x04000000>; /* 64M */ + }; + + /* VGA region is dictated by hardware strapping */ + vga_memory: region at bf000000 { + no-map; + compatible = "shared-dma-pool"; + reg = <0xbf000000 0x01000000>; /* 16M */ + }; + + video_engine_memory: jpegbuffer { + size = <0x02000000>; /* 32M */ + alignment = <0x01000000>; + compatible = "shared-dma-pool"; + reusable; + }; + gfx_memory: framebuffer { + size = <0x01000000>; + alignment = <0x01000000>; + compatible = "shared-dma-pool"; + reusable; + }; + }; + + iio-hwmon { + compatible = "iio-hwmon"; + io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, + <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, + <&adc0 7>, <&adc1 0>; + }; + + gpio-keys { + compatible = "gpio-keys"; + + cpld { + label = "cpld"; + gpios = <&gpio0 ASPEED_GPIO(S, 4) GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + + bmc-heart-beat { + gpios = <&gpio0 ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + bmc-init-ok { + gpios = <&gpio0 ASPEED_GPIO(R, 5) GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + chassis-power-on { + gpios = <&gpio0 ASPEED_GPIO(Q, 3) GPIO_ACTIVE_LOW>; + default-state = "keep"; + }; + + bmc-bootup { + gpios = <&gpio0 ASPEED_GPIO(S, 0) GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + fan-watchdog { + label = "fan-watchdog"; + gpios = <&gpio0 ASPEED_GPIO(E, 0) GPIO_ACTIVE_LOW>; + linux,default-trigger = "timer"; + }; + }; + +}; + +&adc0 { + status = "okay"; + aspeed,int-vref-microvolt = <2500000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc0_default + &pinctrl_adc1_default + &pinctrl_adc2_default + &pinctrl_adc3_default + &pinctrl_adc4_default + &pinctrl_adc5_default + &pinctrl_adc6_default + &pinctrl_adc7_default>; +}; + +&adc1 { + status = "okay"; + aspeed,int-vref-microvolt = <2500000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_adc8_default>; +}; + +&gpio0 { + gpio-line-names = + /*A0-A7*/ "","","","","","","","", + /*B0-B7*/ "","","","","","","","", + /*C0-C7*/ "","","","","","","","", + /*D0-D7*/ "","","","","","","","", + /*E0-E7*/ "","","","","","","","", + /*F0-F7*/ "","","","","","","","", + /*G0-G7*/ "","","","","","","","", + /*H0-H7*/ "","","","","","","","", + /*I0-I7*/ "","","","","","","","", + /*J0-J7*/ "","","","","","","","", + /*K0-K7*/ "","","","","","","","", + /*L0-L7*/ "","","","","","","","", + /*M0-M7*/ "","","","","","","","", + /*N0-N7*/ "","","","","SCM_CPLD_UPDATE_HITLESS","","","", + /*O0-O7*/ "","","","","","","","", + /*P0-P7*/ "","","","","","","","", + /*Q0-Q7*/ "","","","","","FM_PSU1_PRSNT_N","FM_PSU0_PRSNT_N","MB_CPLD_UPDATE_HITLESS", + /*R0-R7*/ "","","","checkstop","","","power-chassis-control","power-button", + /*S0-S7*/ "","","POSTFINISH","","","FM_BATTERY_SENSE_EN","","", + /*T0-T7*/ "","","","","","","","", + /*U0-U7*/ "","","","","","","","", + /*V0-V7*/ "","","","","power-chassis-good","","","", + /*W0-W7*/ "","","","","","","","", + /*X0-X7*/ "","","","","","","","", + /*Y0-Y7*/ "","","","","","","","", + /*Z0-Z7*/ "","","","","","","",""; +}; + +&mdio1 { + status = "okay"; + + ethphy1: ethernet-phy at 0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + }; +}; + +&mac2 { + status = "okay"; + + phy-mode = "rgmii"; + phy-handle = <ðphy1>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rgmii3_default>; +}; + +&mac3 { + status = "okay"; + + phy-mode = "rmii"; + use-ncsi; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_rmii4_default>; +}; + +&emmc_controller { + status = "okay"; +}; + +&pinctrl_emmc_default { + bias-disable; +}; + +&emmc { + status = "okay"; + clk-phase-mmc-hs200 = <180>, <180>; +}; + +#include "ibm-power10-quad.dtsi" +&fsim0 { + cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 4) GPIO_ACTIVE_LOW>; +}; + +&i2c1 { + status = "okay"; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "Sys_Outlet_Temp"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; +}; + +&i2c2 { + status = "okay"; + tmp112 at 40{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "Inlet_Temp"; + }; + + pca9548 at 70{ + compatible = "nxp,pca9548"; + reg = <0x70>; + i2c2s0ch1: i2c at 1{ + reg = <1>; + tmp112 at 49{ + compatible = "ti,tmp112"; + reg = <0x49>; + label = "PSU_Inlet0_Temp"; + }; + tmp112 at 4a{ + compatible = "ti,tmp112"; + reg = <0x4a>; + label = "PSU_Inlet1_Temp"; + }; + }; + i2c2s0ch2: i2c at 2{ + reg = <2>; + tmp112 at 49{ + compatible = "ti,tmp112"; + reg = <0x49>; + label = "L_OCP_ZONE_Temp"; + }; + tmp112 at 4a{ + compatible = "ti,tmp112"; + reg = <0x4a>; + label = "R_OCP_ZONE_Temp"; + }; + }; + }; + + pca0:pca9555 at 20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "OCP0_CABLE_PRSNT_N", "OCP0_BIF2_N", + "OCP0_BIF1_N", "OCP0_BIF0_N", + "OCP0_CARD_PRSNTB3_ISO_N", "OCP0_CARD_PRSNTB2_ISO_N", + "OCP0_CARD_PRSNTB1_ISO_N", "OCP0_CARD_PRSNTB0_ISO_N", + "PE_MCIO0_BP_ID0_Q_N", "PE_MCIO0_BP_ID1_Q_N", + "PE_MCIO1_BP_ID0_Q_N", "PE_MCIO1_BP_ID1_Q_N", + "PE_MCIO2_BP_ID0_Q_N", "PE_MCIO2_BP_ID1_Q_N", + "RISER0_PRSNT_N", "REAR_HDD_PRSNT_N"; + }; + pca1:pca9555 at 21 { + compatible = "nxp,pca9555"; + reg = <0x21>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "OCP1_CABLE_PRSNT_N", "OCP1_BIF2_N", + "OCP1_BIF1_N", "OCP1_BIF0_N", + "OCP1_CARD_PRSNTB3_ISO_N", "OCP1_CARD_PRSNTB2_ISO_N", + "OCP1_CARD_PRSNTB1_ISO_N", "OCP1_CARD_PRSNTB0_ISO_N", + "PE_MCIO3_BP_ID0_Q_N", "PE_MCIO3_BP_ID1_Q_N", + "PE_MCIO4_BP_ID0_Q_N", "PE_MCIO4_BP_ID1_Q_N", + "PE_MCIO5_BP_ID0_Q_N", "PE_MCIO5_BP_ID1_Q_N", + "RISER2_PRSNT_N", "RISER1_PRSNT_N"; + }; + pca2:pca9555 at 22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER2_BOARD_ID1_N", "RISER2_BOARD_ID0_N", + "RISER1_BOARD_ID2_N", "RISER1_BOARD_ID1_N", + "RISER1_BOARD_ID0_N", "RISER0_BOARD_ID2_N", + "RISER0_BOARD_ID1_N", "RISER0_BOARD_ID0_N", + "PE_MCIO6_BP_ID0_Q_N", "PE_MCIO6_BP_ID1_Q_N", + "PE_MCIO7_BP_ID0_Q_N", "PE_MCIO7_BP_ID1_Q_N", + "PE_MCIO8_BP_ID0_Q_N", "PE_MCIO8_BP_ID1_Q_N", + "PE_MCIO9_BP_ID0_Q_N", "PE_MCIO9_BP_ID0_Q_N"; + }; + pca3:pca9555 at 23 { + compatible = "nxp,pca9555"; + reg = <0x23>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", + "", "", + "", "", + "", "RISER2_BOARD_ID2_N", + "PE_MCIO10_BP_ID0_Q_N", "PE_MCIO10_BP_ID1_Q_N", + "PE_MCIO7_BP_ID11_Q_N", "PE_MCIO11_BP_ID1_Q_N", + "PE_MCIO12_BP_ID0_Q_N", "PE_MCIO12_BP_ID1_Q_N", + "PE_MCIO13_BP_ID0_Q_N", "PE_MCIO13_BP_ID0_Q_N"; + }; +}; + +&i2c3 { + status = "okay"; + pca9548 at 70 { + compatible = "nxp,pca9548"; + reg = <0x70>; + }; +}; + +&i2c5 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c5s0ch0: i2c at 0 { + reg = <0>; + status = "okay"; + cpu0vdda at 60 { + compatible = "infineon,xdpe132g5c"; + reg = <0x60>; + }; + cpu0vddb at 61 { + compatible = "infineon,xdpe132g5c"; + reg = <0x61>; + }; + cpu0vdn at 72 { + compatible = "infineon,ir35221"; + reg = <0x72>; + }; + cpu0vio at 73 { + compatible = "infineon,ir35221"; + reg = <0x73>; + }; + cpu0vpci at 74 { + compatible = "infineon,ir35221"; + reg = <0x74>; + }; + }; + i2c5s0ch1: i2c at 1{ + reg = <1>; + status = "okay"; + cpu1vddc at 60 { + compatible = "infineon,xdpe132g5c"; + reg = <0x60>; + }; + cpu1vddd at 61 { + compatible = "infineon,xdpe132g5c"; + reg = <0x61>; + }; + cpu1vdn at 72 { + compatible = "infineon,ir35221"; + reg = <0x72>; + }; + cpu1vio at 73 { + compatible = "infineon,ir35221"; + reg = <0x73>; + }; + cpu1vpci at 74 { + compatible = "infineon,ir35221"; + reg = <0x74>; + }; + }; + i2c5s0ch2: i2c at 2{ + reg = <2>; + status = "okay"; + pxe1610 at 6c { + compatible = "infineon,pxe1610"; + reg = <0x6c>; + }; + rdimm at 74 { + compatible = "infineon,pxe1610"; + reg = <0x74>; + }; + mdimm at 54 { + compatible = "infineon,pxe1610"; + reg = <0x5A>; + }; + ldimm at 44 { + compatible = "infineon,pxe1610"; + reg = <0x5C>; + }; + }; + i2c5s0ch3: i2c at 3{ + reg = <3>; + }; + }; +}; + +&i2c6 { + /* SMB_TEMPSENSOR_STBY_LVC3_R */ + multi-master; + status = "okay"; + + i2c-switch at 70 { + compatible = "nxp,pca9548"; + reg = <0x70>; + #address-cells = <1>; + #size-cells = <0>; + + i2c6s0ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch2: i2c at 2 { + #address-cells = <1>; + #size-cells = <0>; + reg = <2>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + i2c6s0ch3: i2c at 3 { + #address-cells = <1>; + #size-cells = <0>; + reg = <3>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + + pca9548 at 71 { + compatible = "nxp,pca9548"; + reg = <0x71>; + i2c-mux-idle-disconnect; + + i2c6s1ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + i2c6s1ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; + i2c6s0ch4: i2c at 4 { + #address-cells = <1>; + #size-cells = <0>; + reg = <4>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + + pca9548 at 71 { + compatible = "nxp,pca9548"; + reg = <0x71>; + i2c-mux-idle-disconnect; + + i2c6s2ch0: i2c at 0 { + #address-cells = <1>; + #size-cells = <0>; + reg = <0>; + }; + i2c6s2ch1: i2c at 1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + }; + }; + }; + i2c6s0ch5: i2c at 5 { + #address-cells = <1>; + #size-cells = <0>; + reg = <5>; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + tmp1413 at 4c { + compatible = "microchip,emc1413"; + reg = <0x4c>; + }; + }; + }; +}; + +&i2c7 { + status = "okay"; + adc128d818 at 1d{ + compatible = "ti,adc128d818"; + reg = <0x1d>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 1e{ + compatible = "ti,adc128d818"; + reg = <0x1e>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 1f{ + compatible = "ti,adc128d818"; + reg = <0x1f>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2d{ + compatible = "ti,adc128d818"; + reg = <0x2d>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2e{ + compatible = "ti,adc128d818"; + reg = <0x2e>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 2f{ + compatible = "ti,adc128d818"; + reg = <0x2f>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 35{ + compatible = "ti,adc128d818"; + reg = <0x35>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 36{ + compatible = "ti,adc128d818"; + reg = <0x36>; + ti,mode = /bits/ 8 <0x01>; + }; + + adc128d818 at 37{ + compatible = "ti,adc128d818"; + reg = <0x37>; + ti,mode = /bits/ 8 <0x01>; + }; +}; + +&i2c8 { + status = "okay"; + + pca9555 at 24{ + compatible = "nxp,pca9555"; + reg = <0x24>; + #address-cells = <1>; + #size-cells = <0>; + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "FAN_PRSNT5_D_N", "FAN_PRSNT4_D_N", + "FAN_PRSNT3_D_N", "FAN_PRSNT2_D_N", + "FAN_PRSNT1_D_N", "FAN_PRSNT0_D_N", + "", "", + "", "", "", "", + "", "", "", ""; + }; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; + +}; + +&i2c9 { + status = "okay"; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; +}; + +&i2c10 { + status = "okay"; + pca9555 at 20 { + compatible = "nxp,pca9555"; + reg = <0x20>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "DIMM0_FAULT", "DIMM3_FAULT", + "DIMM2_FAULT", "DIMM1_FAULT", + "DIMM4_FAULT", "DIMM5_FAULT", + "DIMM6_FAULT", "DIMM7_FAULT", + "DIMM8_FAULT", "DIMM11_FAULT", + "DIMM10_FAULT", "DIMM9_FAULT", + "DIMM12_FAULT", "DIMM13_FAULT", + "DIMM14_FAULT", "DIMM15_FAULT"; + }; + + pca9555 at 22 { + compatible = "nxp,pca9555"; + reg = <0x22>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", "", "", "OCP0_PRSNT_N", "", "", "", + "", "", "", "", "", "", "", ""; + }; + + pca9555 at 23 { + compatible = "nxp,pca9555"; + reg = <0x23>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "", "", "", "", "OCP1_PRSNT_N", "", "", "", + "", "", "", "", "", "", "", ""; + }; +}; + +&i2c11 { + status = "okay"; + + eeprom at 51 { + compatible = "atmel,24c256"; + reg = <0x51>; + }; +}; + +&i2c12 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c-mux-idle-disconnect; + i2c12s0ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_0"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER0_BOARD_ID7", "RISER0_BOARD_ID6", + "RISER0_BOARD_ID5", "RISER0_BOARD_ID4", + "RISER0_BOARD_ID3", "RISER0_BOARD_ID2", + "RISER0_BOARD_ID1", "RISER0_BOARD_ID0", + "RISER0_SLOT2_PRSNT", "RISER0_SLOT1_PRSNT_X8", + "RISER0_SLOT0_PRSNT_X8", "RISER0_SLOT1_PRSNT_X16", + "RISER0_SLOT0_PRSNT_X16", "", "", ""; + }; + }; + i2c12s0ch1: i2c at 1{ + reg = <1>; + }; + i2c12s0ch2: i2c at 2{ + reg = <2>; + }; + i2c12s0ch3: i2c at 3{ + reg = <3>; + }; + }; + + pca9546 at 71{ + compatible = "nxp,pca9546"; + reg = <0x71>; + i2c-mux-idle-disconnect; + i2c12s1ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_2"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER2_BOARD_ID0", "RISER2_BOARD_ID1", + "RISER2_BOARD_ID2", "RISER2_BOARD_ID3", + "RISER2_BOARD_ID4", "RISER2_BOARD_ID5", + "RISER2_BOARD_ID6", "RISER2_BOARD_ID7", + "RISER2_SLOT0_PRSNT", "RISER2_SLOT1_PRSNT", + "", "", "", "", "", ""; + }; + }; + i2c12s1ch1: i2c at 1{ + reg = <1>; + }; + i2c12s1ch2: i2c at 2{ + reg = <2>; + }; + }; +}; + +&i2c13 { + status = "okay"; + pca9546 at 70{ + compatible = "nxp,pca9546"; + reg = <0x70>; + i2c-mux-idle-disconnect; + i2c13s0ch0: i2c at 0{ + reg = <0>; + tmp112 at 48{ + compatible = "ti,tmp112"; + reg = <0x48>; + label = "PCIE_INLET_1"; + }; + + eeprom at 50 { + compatible = "atmel,24c256"; + reg = <0x50>; + }; + + pca9555 at 24 { + compatible = "nxp,pca9555"; + reg = <0x24>; + + #address-cells = <1>; + #size-cells = <0>; + + gpio-controller; + #gpio-cells = <2>; + + gpio-line-names = + "RISER1_BOARD_ID7", "RISER1_BOARD_ID6", + "RISER1_BOARD_ID5", "RISER1_BOARD_ID4", + "RISER1_BOARD_ID3", "RISER1_BOARD_ID2", + "RISER1_BOARD_ID1", "RISER1_BOARD_ID0", + "RISER1_SLOT2_PRSNT", "RISER1_SLOT1_PRSNT_X8", + "RISER1_SLOT0_PRSNT_X8", "RISER1_SLOT1_PRSNT_X16", + "RISER1_SLOT0_PRSNT_X16", "", "", ""; + }; + }; + i2c13s0ch1: i2c at 1{ + reg = <1>; + }; + i2c13s0ch2: i2c at 2{ + reg = <2>; + }; + i2c13s0ch3: i2c at 3{ + reg = <3>; + }; + }; +}; + +&i2c14 { + status = "okay"; +}; + +&i2c15 { + status = "okay"; +}; + +&ibt { + status = "okay"; +}; + +&uart1 { + status = "okay"; +}; + +&vuart1 { + status = "okay"; +}; + +&vuart2 { + status = "okay"; +}; + +&lpc_ctrl { + status = "okay"; + memory-region = <&flash_memory>; +}; + +&wdt1 { + status = "okay"; +}; + +&kcs2 { + status = "okay"; + aspeed,lpc-io-reg = <0xca8 0xcac>; +}; + +&kcs3 { + status = "okay"; + aspeed,lpc-io-reg = <0xca2>; + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; +}; + +&vhub { + status = "okay"; +}; + +&video { + status = "okay"; + memory-region = <&video_engine_memory>; +}; + +&gfx { + status = "okay"; + memory-region = <&gfx_memory>; +}; -- 2.34.1 From wangzq.jn at gmail.com Wed Dec 20 21:03:19 2023 From: wangzq.jn at gmail.com (John Wang) Date: Wed, 20 Dec 2023 18:03:19 +0800 Subject: [PATCH v2] ARM: dts: aspeed: Add IEISystems FP5280G3 BMC machine In-Reply-To: <20231220095004.2036251-1-liuxiwei@ieisystem.com> References: <20231220095004.2036251-1-liuxiwei@ieisystem.com> Message-ID: On Wed, Dec 20, 2023 at 5:50?PM George Liu wrote: > > The IEISystems FP5280G3 is a power platform server with an > AST2600-based BMC. > This dts file provides a basic configuration for its OpenBMC > development. > > Signed-off-by: George Liu Reviewed-by: John Wang Tested-by: John Wang > --- > v1 -> v2 > - Include ibm-power10-quad.dtsi > - Remove redundant blank lines > - Remove nct7362 driver > - Remove bus-timeout-ms & bus-recover-timeout-ms > - Remove reset-mask1 > --- > arch/arm/boot/dts/aspeed/Makefile | 1 + > .../aspeed/aspeed-bmc-ieisystems-fp5280g3.dts | 966 ++++++++++++++++++ > 2 files changed, 967 insertions(+) > create mode 100644 arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > > diff --git a/arch/arm/boot/dts/aspeed/Makefile b/arch/arm/boot/dts/aspeed/Makefile > index fb9cc95f1b60..6017ff5b7959 100644 > --- a/arch/arm/boot/dts/aspeed/Makefile > +++ b/arch/arm/boot/dts/aspeed/Makefile > @@ -36,6 +36,7 @@ dtb-$(CONFIG_ARCH_ASPEED) += \ > aspeed-bmc-ibm-rainier.dtb \ > aspeed-bmc-ibm-rainier-1s4u.dtb \ > aspeed-bmc-ibm-rainier-4u.dtb \ > + aspeed-bmc-ieisystems-fp5280g3.dtb \ > aspeed-bmc-intel-s2600wf.dtb \ > aspeed-bmc-inspur-fp5280g2.dtb \ > aspeed-bmc-inspur-nf5280m6.dtb \ > diff --git a/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > new file mode 100644 > index 000000000000..51f0c8903b63 > --- /dev/null > +++ b/arch/arm/boot/dts/aspeed/aspeed-bmc-ieisystems-fp5280g3.dts > @@ -0,0 +1,966 @@ > +// SPDX-License-Identifier: GPL-2.0 > +// Copyright (c) 2023, IEISystems Corporation > + > +/dts-v1/; > + > +#include "aspeed-g6.dtsi" > +#include > +#include > + > +/ { > + model = "FP5280G3 BMC"; > + compatible = "ieisystems,fp5280g3-bmc", "aspeed,ast2600"; > + > + aliases { > + i2c2001 = &i2c2s0ch1; > + i2c2002 = &i2c2s0ch2; > + i2c5000 = &i2c5s0ch0; > + i2c5001 = &i2c5s0ch1; > + i2c5002 = &i2c5s0ch2; > + i2c5003 = &i2c5s0ch3; > + i2c6000 = &i2c6s0ch0; > + i2c6001 = &i2c6s0ch1; > + i2c6002 = &i2c6s0ch2; > + i2c6003 = &i2c6s0ch3; > + i2c6004 = &i2c6s0ch4; > + i2c6005 = &i2c6s0ch5; > + i2c6100 = &i2c6s1ch0; > + i2c6101 = &i2c6s1ch1; > + i2c6200 = &i2c6s2ch0; > + i2c6201 = &i2c6s2ch1; > + i2c12000 = &i2c12s0ch0; > + i2c12001 = &i2c12s0ch1; > + i2c12002 = &i2c12s0ch2; > + i2c12003 = &i2c12s0ch3; > + i2c12100 = &i2c12s1ch0; > + i2c12101 = &i2c12s1ch1; > + i2c12102 = &i2c12s1ch2; > + i2c13000 = &i2c13s0ch0; > + i2c13001 = &i2c13s0ch1; > + i2c13002 = &i2c13s0ch2; > + i2c13003 = &i2c13s0ch3; > + }; > + > + chosen { > + stdout-path = &uart5; > + bootargs = "console=ttyS4,115200n8 earlycon"; > + }; > + > + memory at 80000000 { > + device_type = "memory"; > + reg = <0x80000000 0x80000000>; > + }; > + > + reserved-memory { > + #address-cells = <1>; > + #size-cells = <1>; > + ranges; > + > + ramoops at b3e00000 { > + compatible = "ramoops"; > + reg = <0xb3e00000 0x200000>; /* 16 * (4 * 0x8000) */ > + record-size = <0x8000>; > + console-size = <0x8000>; > + ftrace-size = <0x8000>; > + pmsg-size = <0x8000>; > + max-reason = <3>; /* KMSG_DUMP_EMERG */ > + }; > + > + /* LPC FW cycle bridge region requires natural alignment */ > + flash_memory: region at b4000000 { > + no-map; > + reg = <0xb4000000 0x04000000>; /* 64M */ > + }; > + > + /* VGA region is dictated by hardware strapping */ > + vga_memory: region at bf000000 { > + no-map; > + compatible = "shared-dma-pool"; > + reg = <0xbf000000 0x01000000>; /* 16M */ > + }; > + > + video_engine_memory: jpegbuffer { > + size = <0x02000000>; /* 32M */ > + alignment = <0x01000000>; > + compatible = "shared-dma-pool"; > + reusable; > + }; > + gfx_memory: framebuffer { > + size = <0x01000000>; > + alignment = <0x01000000>; > + compatible = "shared-dma-pool"; > + reusable; > + }; > + }; > + > + iio-hwmon { > + compatible = "iio-hwmon"; > + io-channels = <&adc0 0>, <&adc0 1>, <&adc0 2>, > + <&adc0 3>, <&adc0 4>, <&adc0 5>, <&adc0 6>, > + <&adc0 7>, <&adc1 0>; > + }; > + > + gpio-keys { > + compatible = "gpio-keys"; > + > + cpld { > + label = "cpld"; > + gpios = <&gpio0 ASPEED_GPIO(S, 4) GPIO_ACTIVE_HIGH>; > + linux,code = ; > + }; > + }; > + > + leds { > + compatible = "gpio-leds"; > + > + bmc-heart-beat { > + gpios = <&gpio0 ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>; > + default-state = "keep"; > + }; > + > + bmc-init-ok { > + gpios = <&gpio0 ASPEED_GPIO(R, 5) GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + chassis-power-on { > + gpios = <&gpio0 ASPEED_GPIO(Q, 3) GPIO_ACTIVE_LOW>; > + default-state = "keep"; > + }; > + > + bmc-bootup { > + gpios = <&gpio0 ASPEED_GPIO(S, 0) GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + fan-watchdog { > + label = "fan-watchdog"; > + gpios = <&gpio0 ASPEED_GPIO(E, 0) GPIO_ACTIVE_LOW>; > + linux,default-trigger = "timer"; > + }; > + }; > + > +}; > + > +&adc0 { > + status = "okay"; > + aspeed,int-vref-microvolt = <2500000>; > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_adc0_default > + &pinctrl_adc1_default > + &pinctrl_adc2_default > + &pinctrl_adc3_default > + &pinctrl_adc4_default > + &pinctrl_adc5_default > + &pinctrl_adc6_default > + &pinctrl_adc7_default>; > +}; > + > +&adc1 { > + status = "okay"; > + aspeed,int-vref-microvolt = <2500000>; > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_adc8_default>; > +}; > + > +&gpio0 { > + gpio-line-names = > + /*A0-A7*/ "","","","","","","","", > + /*B0-B7*/ "","","","","","","","", > + /*C0-C7*/ "","","","","","","","", > + /*D0-D7*/ "","","","","","","","", > + /*E0-E7*/ "","","","","","","","", > + /*F0-F7*/ "","","","","","","","", > + /*G0-G7*/ "","","","","","","","", > + /*H0-H7*/ "","","","","","","","", > + /*I0-I7*/ "","","","","","","","", > + /*J0-J7*/ "","","","","","","","", > + /*K0-K7*/ "","","","","","","","", > + /*L0-L7*/ "","","","","","","","", > + /*M0-M7*/ "","","","","","","","", > + /*N0-N7*/ "","","","","SCM_CPLD_UPDATE_HITLESS","","","", > + /*O0-O7*/ "","","","","","","","", > + /*P0-P7*/ "","","","","","","","", > + /*Q0-Q7*/ "","","","","","FM_PSU1_PRSNT_N","FM_PSU0_PRSNT_N","MB_CPLD_UPDATE_HITLESS", > + /*R0-R7*/ "","","","checkstop","","","power-chassis-control","power-button", > + /*S0-S7*/ "","","POSTFINISH","","","FM_BATTERY_SENSE_EN","","", > + /*T0-T7*/ "","","","","","","","", > + /*U0-U7*/ "","","","","","","","", > + /*V0-V7*/ "","","","","power-chassis-good","","","", > + /*W0-W7*/ "","","","","","","","", > + /*X0-X7*/ "","","","","","","","", > + /*Y0-Y7*/ "","","","","","","","", > + /*Z0-Z7*/ "","","","","","","",""; > +}; > + > +&mdio1 { > + status = "okay"; > + > + ethphy1: ethernet-phy at 0 { > + compatible = "ethernet-phy-ieee802.3-c22"; > + reg = <0>; > + }; > +}; > + > +&mac2 { > + status = "okay"; > + > + phy-mode = "rgmii"; > + phy-handle = <ðphy1>; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_rgmii3_default>; > +}; > + > +&mac3 { > + status = "okay"; > + > + phy-mode = "rmii"; > + use-ncsi; > + > + pinctrl-names = "default"; > + pinctrl-0 = <&pinctrl_rmii4_default>; > +}; > + > +&emmc_controller { > + status = "okay"; > +}; > + > +&pinctrl_emmc_default { > + bias-disable; > +}; > + > +&emmc { > + status = "okay"; > + clk-phase-mmc-hs200 = <180>, <180>; > +}; > + > +#include "ibm-power10-quad.dtsi" > +&fsim0 { > + cfam-reset-gpios = <&gpio0 ASPEED_GPIO(Q, 4) GPIO_ACTIVE_LOW>; > +}; > + > +&i2c1 { > + status = "okay"; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "Sys_Outlet_Temp"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > +}; > + > +&i2c2 { > + status = "okay"; > + tmp112 at 40{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "Inlet_Temp"; > + }; > + > + pca9548 at 70{ > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + i2c2s0ch1: i2c at 1{ > + reg = <1>; > + tmp112 at 49{ > + compatible = "ti,tmp112"; > + reg = <0x49>; > + label = "PSU_Inlet0_Temp"; > + }; > + tmp112 at 4a{ > + compatible = "ti,tmp112"; > + reg = <0x4a>; > + label = "PSU_Inlet1_Temp"; > + }; > + }; > + i2c2s0ch2: i2c at 2{ > + reg = <2>; > + tmp112 at 49{ > + compatible = "ti,tmp112"; > + reg = <0x49>; > + label = "L_OCP_ZONE_Temp"; > + }; > + tmp112 at 4a{ > + compatible = "ti,tmp112"; > + reg = <0x4a>; > + label = "R_OCP_ZONE_Temp"; > + }; > + }; > + }; > + > + pca0:pca9555 at 20 { > + compatible = "nxp,pca9555"; > + reg = <0x20>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "OCP0_CABLE_PRSNT_N", "OCP0_BIF2_N", > + "OCP0_BIF1_N", "OCP0_BIF0_N", > + "OCP0_CARD_PRSNTB3_ISO_N", "OCP0_CARD_PRSNTB2_ISO_N", > + "OCP0_CARD_PRSNTB1_ISO_N", "OCP0_CARD_PRSNTB0_ISO_N", > + "PE_MCIO0_BP_ID0_Q_N", "PE_MCIO0_BP_ID1_Q_N", > + "PE_MCIO1_BP_ID0_Q_N", "PE_MCIO1_BP_ID1_Q_N", > + "PE_MCIO2_BP_ID0_Q_N", "PE_MCIO2_BP_ID1_Q_N", > + "RISER0_PRSNT_N", "REAR_HDD_PRSNT_N"; > + }; > + pca1:pca9555 at 21 { > + compatible = "nxp,pca9555"; > + reg = <0x21>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "OCP1_CABLE_PRSNT_N", "OCP1_BIF2_N", > + "OCP1_BIF1_N", "OCP1_BIF0_N", > + "OCP1_CARD_PRSNTB3_ISO_N", "OCP1_CARD_PRSNTB2_ISO_N", > + "OCP1_CARD_PRSNTB1_ISO_N", "OCP1_CARD_PRSNTB0_ISO_N", > + "PE_MCIO3_BP_ID0_Q_N", "PE_MCIO3_BP_ID1_Q_N", > + "PE_MCIO4_BP_ID0_Q_N", "PE_MCIO4_BP_ID1_Q_N", > + "PE_MCIO5_BP_ID0_Q_N", "PE_MCIO5_BP_ID1_Q_N", > + "RISER2_PRSNT_N", "RISER1_PRSNT_N"; > + }; > + pca2:pca9555 at 22 { > + compatible = "nxp,pca9555"; > + reg = <0x22>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER2_BOARD_ID1_N", "RISER2_BOARD_ID0_N", > + "RISER1_BOARD_ID2_N", "RISER1_BOARD_ID1_N", > + "RISER1_BOARD_ID0_N", "RISER0_BOARD_ID2_N", > + "RISER0_BOARD_ID1_N", "RISER0_BOARD_ID0_N", > + "PE_MCIO6_BP_ID0_Q_N", "PE_MCIO6_BP_ID1_Q_N", > + "PE_MCIO7_BP_ID0_Q_N", "PE_MCIO7_BP_ID1_Q_N", > + "PE_MCIO8_BP_ID0_Q_N", "PE_MCIO8_BP_ID1_Q_N", > + "PE_MCIO9_BP_ID0_Q_N", "PE_MCIO9_BP_ID0_Q_N"; > + }; > + pca3:pca9555 at 23 { > + compatible = "nxp,pca9555"; > + reg = <0x23>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", > + "", "", > + "", "", > + "", "RISER2_BOARD_ID2_N", > + "PE_MCIO10_BP_ID0_Q_N", "PE_MCIO10_BP_ID1_Q_N", > + "PE_MCIO7_BP_ID11_Q_N", "PE_MCIO11_BP_ID1_Q_N", > + "PE_MCIO12_BP_ID0_Q_N", "PE_MCIO12_BP_ID1_Q_N", > + "PE_MCIO13_BP_ID0_Q_N", "PE_MCIO13_BP_ID0_Q_N"; > + }; > +}; > + > +&i2c3 { > + status = "okay"; > + pca9548 at 70 { > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + }; > +}; > + > +&i2c5 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c5s0ch0: i2c at 0 { > + reg = <0>; > + status = "okay"; > + cpu0vdda at 60 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x60>; > + }; > + cpu0vddb at 61 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x61>; > + }; > + cpu0vdn at 72 { > + compatible = "infineon,ir35221"; > + reg = <0x72>; > + }; > + cpu0vio at 73 { > + compatible = "infineon,ir35221"; > + reg = <0x73>; > + }; > + cpu0vpci at 74 { > + compatible = "infineon,ir35221"; > + reg = <0x74>; > + }; > + }; > + i2c5s0ch1: i2c at 1{ > + reg = <1>; > + status = "okay"; > + cpu1vddc at 60 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x60>; > + }; > + cpu1vddd at 61 { > + compatible = "infineon,xdpe132g5c"; > + reg = <0x61>; > + }; > + cpu1vdn at 72 { > + compatible = "infineon,ir35221"; > + reg = <0x72>; > + }; > + cpu1vio at 73 { > + compatible = "infineon,ir35221"; > + reg = <0x73>; > + }; > + cpu1vpci at 74 { > + compatible = "infineon,ir35221"; > + reg = <0x74>; > + }; > + }; > + i2c5s0ch2: i2c at 2{ > + reg = <2>; > + status = "okay"; > + pxe1610 at 6c { > + compatible = "infineon,pxe1610"; > + reg = <0x6c>; > + }; > + rdimm at 74 { > + compatible = "infineon,pxe1610"; > + reg = <0x74>; > + }; > + mdimm at 54 { > + compatible = "infineon,pxe1610"; > + reg = <0x5A>; > + }; > + ldimm at 44 { > + compatible = "infineon,pxe1610"; > + reg = <0x5C>; > + }; > + }; > + i2c5s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > +}; > + > +&i2c6 { > + /* SMB_TEMPSENSOR_STBY_LVC3_R */ > + multi-master; > + status = "okay"; > + > + i2c-switch at 70 { > + compatible = "nxp,pca9548"; > + reg = <0x70>; > + #address-cells = <1>; > + #size-cells = <0>; > + > + i2c6s0ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch2: i2c at 2 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <2>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + i2c6s0ch3: i2c at 3 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <3>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + > + pca9548 at 71 { > + compatible = "nxp,pca9548"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + > + i2c6s1ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + }; > + i2c6s1ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + }; > + }; > + }; > + i2c6s0ch4: i2c at 4 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <4>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + > + pca9548 at 71 { > + compatible = "nxp,pca9548"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + > + i2c6s2ch0: i2c at 0 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <0>; > + }; > + i2c6s2ch1: i2c at 1 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <1>; > + }; > + }; > + }; > + i2c6s0ch5: i2c at 5 { > + #address-cells = <1>; > + #size-cells = <0>; > + reg = <5>; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + tmp1413 at 4c { > + compatible = "microchip,emc1413"; > + reg = <0x4c>; > + }; > + }; > + }; > +}; > + > +&i2c7 { > + status = "okay"; > + adc128d818 at 1d{ > + compatible = "ti,adc128d818"; > + reg = <0x1d>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 1e{ > + compatible = "ti,adc128d818"; > + reg = <0x1e>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 1f{ > + compatible = "ti,adc128d818"; > + reg = <0x1f>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2d{ > + compatible = "ti,adc128d818"; > + reg = <0x2d>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2e{ > + compatible = "ti,adc128d818"; > + reg = <0x2e>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 2f{ > + compatible = "ti,adc128d818"; > + reg = <0x2f>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 35{ > + compatible = "ti,adc128d818"; > + reg = <0x35>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 36{ > + compatible = "ti,adc128d818"; > + reg = <0x36>; > + ti,mode = /bits/ 8 <0x01>; > + }; > + > + adc128d818 at 37{ > + compatible = "ti,adc128d818"; > + reg = <0x37>; > + ti,mode = /bits/ 8 <0x01>; > + }; > +}; > + > +&i2c8 { > + status = "okay"; > + > + pca9555 at 24{ > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + #address-cells = <1>; > + #size-cells = <0>; > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "FAN_PRSNT5_D_N", "FAN_PRSNT4_D_N", > + "FAN_PRSNT3_D_N", "FAN_PRSNT2_D_N", > + "FAN_PRSNT1_D_N", "FAN_PRSNT0_D_N", > + "", "", > + "", "", "", "", > + "", "", "", ""; > + }; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > + > +}; > + > +&i2c9 { > + status = "okay"; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > +}; > + > +&i2c10 { > + status = "okay"; > + pca9555 at 20 { > + compatible = "nxp,pca9555"; > + reg = <0x20>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "DIMM0_FAULT", "DIMM3_FAULT", > + "DIMM2_FAULT", "DIMM1_FAULT", > + "DIMM4_FAULT", "DIMM5_FAULT", > + "DIMM6_FAULT", "DIMM7_FAULT", > + "DIMM8_FAULT", "DIMM11_FAULT", > + "DIMM10_FAULT", "DIMM9_FAULT", > + "DIMM12_FAULT", "DIMM13_FAULT", > + "DIMM14_FAULT", "DIMM15_FAULT"; > + }; > + > + pca9555 at 22 { > + compatible = "nxp,pca9555"; > + reg = <0x22>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", "", "", "OCP0_PRSNT_N", "", "", "", > + "", "", "", "", "", "", "", ""; > + }; > + > + pca9555 at 23 { > + compatible = "nxp,pca9555"; > + reg = <0x23>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "", "", "", "", "OCP1_PRSNT_N", "", "", "", > + "", "", "", "", "", "", "", ""; > + }; > +}; > + > +&i2c11 { > + status = "okay"; > + > + eeprom at 51 { > + compatible = "atmel,24c256"; > + reg = <0x51>; > + }; > +}; > + > +&i2c12 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c-mux-idle-disconnect; > + i2c12s0ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_0"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER0_BOARD_ID7", "RISER0_BOARD_ID6", > + "RISER0_BOARD_ID5", "RISER0_BOARD_ID4", > + "RISER0_BOARD_ID3", "RISER0_BOARD_ID2", > + "RISER0_BOARD_ID1", "RISER0_BOARD_ID0", > + "RISER0_SLOT2_PRSNT", "RISER0_SLOT1_PRSNT_X8", > + "RISER0_SLOT0_PRSNT_X8", "RISER0_SLOT1_PRSNT_X16", > + "RISER0_SLOT0_PRSNT_X16", "", "", ""; > + }; > + }; > + i2c12s0ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c12s0ch2: i2c at 2{ > + reg = <2>; > + }; > + i2c12s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > + > + pca9546 at 71{ > + compatible = "nxp,pca9546"; > + reg = <0x71>; > + i2c-mux-idle-disconnect; > + i2c12s1ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_2"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER2_BOARD_ID0", "RISER2_BOARD_ID1", > + "RISER2_BOARD_ID2", "RISER2_BOARD_ID3", > + "RISER2_BOARD_ID4", "RISER2_BOARD_ID5", > + "RISER2_BOARD_ID6", "RISER2_BOARD_ID7", > + "RISER2_SLOT0_PRSNT", "RISER2_SLOT1_PRSNT", > + "", "", "", "", "", ""; > + }; > + }; > + i2c12s1ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c12s1ch2: i2c at 2{ > + reg = <2>; > + }; > + }; > +}; > + > +&i2c13 { > + status = "okay"; > + pca9546 at 70{ > + compatible = "nxp,pca9546"; > + reg = <0x70>; > + i2c-mux-idle-disconnect; > + i2c13s0ch0: i2c at 0{ > + reg = <0>; > + tmp112 at 48{ > + compatible = "ti,tmp112"; > + reg = <0x48>; > + label = "PCIE_INLET_1"; > + }; > + > + eeprom at 50 { > + compatible = "atmel,24c256"; > + reg = <0x50>; > + }; > + > + pca9555 at 24 { > + compatible = "nxp,pca9555"; > + reg = <0x24>; > + > + #address-cells = <1>; > + #size-cells = <0>; > + > + gpio-controller; > + #gpio-cells = <2>; > + > + gpio-line-names = > + "RISER1_BOARD_ID7", "RISER1_BOARD_ID6", > + "RISER1_BOARD_ID5", "RISER1_BOARD_ID4", > + "RISER1_BOARD_ID3", "RISER1_BOARD_ID2", > + "RISER1_BOARD_ID1", "RISER1_BOARD_ID0", > + "RISER1_SLOT2_PRSNT", "RISER1_SLOT1_PRSNT_X8", > + "RISER1_SLOT0_PRSNT_X8", "RISER1_SLOT1_PRSNT_X16", > + "RISER1_SLOT0_PRSNT_X16", "", "", ""; > + }; > + }; > + i2c13s0ch1: i2c at 1{ > + reg = <1>; > + }; > + i2c13s0ch2: i2c at 2{ > + reg = <2>; > + }; > + i2c13s0ch3: i2c at 3{ > + reg = <3>; > + }; > + }; > +}; > + > +&i2c14 { > + status = "okay"; > +}; > + > +&i2c15 { > + status = "okay"; > +}; > + > +&ibt { > + status = "okay"; > +}; > + > +&uart1 { > + status = "okay"; > +}; > + > +&vuart1 { > + status = "okay"; > +}; > + > +&vuart2 { > + status = "okay"; > +}; > + > +&lpc_ctrl { > + status = "okay"; > + memory-region = <&flash_memory>; > +}; > + > +&wdt1 { > + status = "okay"; > +}; > + > +&kcs2 { > + status = "okay"; > + aspeed,lpc-io-reg = <0xca8 0xcac>; > +}; > + > +&kcs3 { > + status = "okay"; > + aspeed,lpc-io-reg = <0xca2>; > + aspeed,lpc-interrupts = <11 IRQ_TYPE_LEVEL_LOW>; > +}; > + > +&vhub { > + status = "okay"; > +}; > + > +&video { > + status = "okay"; > + memory-region = <&video_engine_memory>; > +}; > + > +&gfx { > + status = "okay"; > + memory-region = <&gfx_memory>; > +}; > -- > 2.34.1 > From adrian.ambrozewicz at linux.intel.com Thu Dec 21 01:18:38 2023 From: adrian.ambrozewicz at linux.intel.com (Ambrozewicz, Adrian) Date: Wed, 20 Dec 2023 15:18:38 +0100 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> Message-ID: <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> I would like to apologize for this issue. We were undergoing serious reorganization recently and this indeed flew under the radar. Currently we've integrated proposed changes and wait for feedback from automated regression test suite. Regards, Adrian W dniu 18.12.2023 o?00:54, Andrew Jeffery pisze: > Hello Adrian, Jozef, and Cezary, > > A complaint has been raised to the Technical Oversight Forum that as > maintainers you collectively have not responded to several patches for > openbmc/telemetry in a reasonable timeframe. > > Some time ago the project defined constraints on timeliness for > reviews. This helps to set expectations for both contributors and > maintainers. Maintainers are expected to find time to provide feedback > on patches inside one month of them being pushed to Gerrit. Upon > complaint, missing this deadline forms one count of unresponsiveness. > If a subproject's maintainers receive three complaints of > unresponsiveness in a 12 month period then the Technical Oversight > Forum will seek to introduce new maintainers to the subproject. > > This is the first notice of a complaint of unresponsiveness for > openbmc/telemetry. > > This notice is copied to the OpenBMC mailing list to provide community > visibility. We need the process to be both public and archived to make > sure we are clear and accountable in our communication. > > Further details and considerations of this policy are defined at the > link below: > > https://github.com/openbmc/docs/blob/master/process/subproject-maintainership.md > > The complaint regarding openbmc/telemetry at: > > https://github.com/openbmc/technical-oversight-forum/issues/32 > > The specific patches identified by the complaint are: > > 1. 64867: build: upgrade to C++23 > https://gerrit.openbmc.org/c/openbmc/telemetry/+/64867 > > 2. 67240: clang-format: copy latest and re-format > https://gerrit.openbmc.org/c/openbmc/telemetry/+/67240 > > 3. 66007: meson_options.txt: Support for reading options from meson.options > https://gerrit.openbmc.org/c/openbmc/telemetry/+/66007 > > If you are unable to continue with your maintenance role for > openbmc/telemetry then please work with the community identify others > who are capable and willing. When doing so, please consider the > expectations set out in the community membership documentation: > > https://github.com/openbmc/docs/blob/master/community-membership.md > > On behalf of the Technical Oversight Forum, > > Andrew From patrick at stwcx.xyz Thu Dec 21 02:22:18 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Wed, 20 Dec 2023 09:22:18 -0600 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> Message-ID: On Wed, Dec 20, 2023 at 03:18:38PM +0100, Ambrozewicz, Adrian wrote: > > Currently we've integrated proposed changes and wait for feedback from > automated regression test suite. Hi Adrian, What did you mean by this? Commits go through CI when they are submitted. I don't see any change in Gerrit for any of the 3 commits. If you have an internal test suite you haven't contributed upstream and you are holding off merging commits until you run them through a private test suite, this is unacceptable for the open source project. -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From adrian.ambrozewicz at linux.intel.com Thu Dec 21 03:03:21 2023 From: adrian.ambrozewicz at linux.intel.com (Ambrozewicz, Adrian) Date: Wed, 20 Dec 2023 17:03:21 +0100 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> Message-ID: What I mean are functional tests on target, with real BMC, board, and sensors. Could you point me to examples where it's documented or done in automated CI for other subprojects? Or perhaps do you meen that maintainer stalling the change until he makes sure it doesn't break various configurations is unacceptable? Then IMHO I won't aggree, as code compiled within unit tests is just one arch, yet alone separated from rest of the system. Regards, Adrian W dniu 20.12.2023 o?16:22, Patrick Williams pisze: > On Wed, Dec 20, 2023 at 03:18:38PM +0100, Ambrozewicz, Adrian wrote: >> >> Currently we've integrated proposed changes and wait for feedback from >> automated regression test suite. > > Hi Adrian, > > What did you mean by this? Commits go through CI when they are > submitted. I don't see any change in Gerrit for any of the 3 commits. > > If you have an internal test suite you haven't contributed upstream and you > are holding off merging commits until you run them through a private test suite, > this is unacceptable for the open source project. > From patrick at stwcx.xyz Thu Dec 21 03:56:50 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Wed, 20 Dec 2023 10:56:50 -0600 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> Message-ID: On Wed, Dec 20, 2023 at 05:03:21PM +0100, Ambrozewicz, Adrian wrote: > What I mean are functional tests on target, with real BMC, board, and > sensors. openbmc/telemetry doesn't interact with any of these things directly. sensors are covered by dbus-sensors, etc. What you are describing is an integration test that belongs in openbmc-test-automation with all the other integration / functional tests. If you want to make sure that openbmc/telemetry reacts to the dbus model correctly (which is the only thing that belongs in a repository-level test) you should mock that out as a unit test. > Could you point me to examples where it's documented or done in > automated CI for other subprojects? See openbmc-test-automation test cases that currently run on QEMU as part of Romulus and you can talk to Andrew about the hardware tests that run on Witherspoon (which are non-blocking but he keeps on top of the failure reports). > Or perhaps do you meen that maintainer stalling the change until he > makes sure it doesn't break various configurations is unacceptable? Then > IMHO I won't aggree, as code compiled within unit tests is just one > arch, yet alone separated from rest of the system. There are many problems with your position from an open source perspective. These are the ones that are top of mind to me: 1. You have no idea if the breakage is due to the submitters proposed change or because of a change in another repository. 2. You've made up your own test framework that nobody else has visibility to. That means you're effectively treating openbmc/telemetry as your own sandbox and are not collaborating with the rest of the project. 3. Your delay in integrating changes can have velocity impacts to the rest of the project when we _require_ repository-level changes in order to integrate a Yocto update, etc. 4. Your position is that you will reject someone's commit because it breaks your internal test. They have no visibility to this test, they have no way to know that they are "breaking you", and they have no possible course of action to recover from any issue you report. If you want to have your own tests to test integration of openbmc/telemetry (along with other open source components) with your own project you are more than welcome to do that (even though I think it would be far more beneficial to enhance openbmc-test-automation). That should probably be happening when you import openbmc/openbmc into your own internal tree, but if you want to give yourself early signal to these failures, that is okay. My gripe is that you should not be holding up the open-source project for your own unpublished, undocumented, non-aligned tests. > W dniu 20.12.2023 o?16:22, Patrick Williams pisze: > > On Wed, Dec 20, 2023 at 03:18:38PM +0100, Ambrozewicz, Adrian wrote: > >> > >> Currently we've integrated proposed changes and wait for feedback from > >> automated regression test suite. > > > > Hi Adrian, > > > > What did you mean by this? Commits go through CI when they are > > submitted. I don't see any change in Gerrit for any of the 3 commits. > > > > If you have an internal test suite you haven't contributed upstream and you > > are holding off merging commits until you run them through a private test suite, > > this is unacceptable for the open source project. > > -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From sboyd at kernel.org Thu Dec 21 09:09:05 2023 From: sboyd at kernel.org (Stephen Boyd) Date: Wed, 20 Dec 2023 14:09:05 -0800 Subject: [PATCH RESEND v21] clk: npcm8xx: add clock controller In-Reply-To: <20231218170404.910153-1-tmaimon77@gmail.com> References: <20231218170404.910153-1-tmaimon77@gmail.com> Message-ID: <7c322ab2ab59b434429ce471c148c026.sboyd@kernel.org> Quoting Tomer Maimon (2023-12-18 09:04:04) > diff --git a/drivers/clk/clk-npcm8xx.c b/drivers/clk/clk-npcm8xx.c > new file mode 100644 > index 000000000000..e6c5111cc255 > --- /dev/null > +++ b/drivers/clk/clk-npcm8xx.c > @@ -0,0 +1,552 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Nuvoton NPCM8xx Clock Generator > + * All the clocks are initialized by the bootloader, so this driver allows only > + * reading of current settings directly from the hardware. > + * > + * Copyright (C) 2020 Nuvoton Technologies > + * Author: Tomer Maimon > + */ > + > +#define pr_fmt(fmt) "npcm8xx_clk: " fmt > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include [...] > +#define NPCM8XX_CLK_S_CLKOUT "clkout" > +#define NPCM8XX_CLK_S_PRE_ADC "pre adc" > +#define NPCM8XX_CLK_S_UART "uart" > +#define NPCM8XX_CLK_S_UART2 "uart2" > +#define NPCM8XX_CLK_S_TIMER "timer" > +#define NPCM8XX_CLK_S_MMC "mmc" > +#define NPCM8XX_CLK_S_SDHC "sdhc" > +#define NPCM8XX_CLK_S_ADC "adc" > +#define NPCM8XX_CLK_S_GFX "gfx0_gfx1_mem" > +#define NPCM8XX_CLK_S_USBIF "serial_usbif" > +#define NPCM8XX_CLK_S_USB_HOST "usb_host" > +#define NPCM8XX_CLK_S_USB_BRIDGE "usb_bridge" > +#define NPCM8XX_CLK_S_PCI "pci" > +#define NPCM8XX_CLK_S_TH "th" > +#define NPCM8XX_CLK_S_ATB "atb" > +#define NPCM8XX_CLK_S_PRE_CLK "pre_clk" > +#define NPCM8XX_CLK_S_RG "rg" > +#define NPCM8XX_CLK_S_RCP "rcp" > + > +static struct clk_hw hw_pll1_div2, hw_pll2_div2, hw_gfx_div2, hw_pre_clk; > +static struct npcm8xx_clk_pll_data npcm8xx_pll_clks[] = { > + { NPCM8XX_CLK_S_PLL0, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON0, 0 }, This is a new driver, so please stop using .name in clk_parent_data structures. > + { NPCM8XX_CLK_S_PLL1, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON1, 0 }, > + { NPCM8XX_CLK_S_PLL2, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON2, 0 }, > + { NPCM8XX_CLK_S_PLL_GFX, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCONG, 0 }, > +}; > + > +static const u32 cpuck_mux_table[] = { 0, 1, 2, 7 }; > +static const struct clk_parent_data cpuck_mux_parents[] = { > + { .hw = &npcm8xx_pll_clks[0].hw }, > + { .hw = &npcm8xx_pll_clks[1].hw }, > + { .index = 0 }, This requires a binding update. As of today, there isn't a 'clocks' property for the nuvoton,npcm845-clk binding. > + { .hw = &npcm8xx_pll_clks[2].hw } > +}; > + > +static const u32 pixcksel_mux_table[] = { 0, 2 }; > +static const struct clk_parent_data pixcksel_mux_parents[] = { > + { .hw = &npcm8xx_pll_clks[3].hw }, > + { .index = 0 } > +}; > + [...] > + > +/* configurable dividers: */ > +static struct npcm8xx_clk_div_data npcm8xx_divs[] = { > + { NPCM8XX_CLKDIV1, 28, 3, NPCM8XX_CLK_S_ADC, &npcm8xx_pre_divs[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_ADC }, > + { NPCM8XX_CLKDIV1, 16, 5, NPCM8XX_CLK_S_UART, &npcm8xx_muxes[3].hw, 0, 0, NPCM8XX_CLK_UART }, > + { NPCM8XX_CLKDIV1, 11, 5, NPCM8XX_CLK_S_MMC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_MMC }, > + { NPCM8XX_CLKDIV1, 6, 5, NPCM8XX_CLK_S_SPI3, &npcm8xx_pre_divs[1].hw, 0, 0, NPCM8XX_CLK_SPI3 }, > + { NPCM8XX_CLKDIV1, 2, 4, NPCM8XX_CLK_S_PCI, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_PCI }, > + > + { NPCM8XX_CLKDIV2, 30, 2, NPCM8XX_CLK_S_APB4, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB4 }, > + { NPCM8XX_CLKDIV2, 28, 2, NPCM8XX_CLK_S_APB3, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB3 }, > + { NPCM8XX_CLKDIV2, 26, 2, NPCM8XX_CLK_S_APB2, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB2 }, > + { NPCM8XX_CLKDIV2, 24, 2, NPCM8XX_CLK_S_APB1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB1 }, > + { NPCM8XX_CLKDIV2, 22, 2, NPCM8XX_CLK_S_APB5, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB5 }, > + { NPCM8XX_CLKDIV2, 16, 5, NPCM8XX_CLK_S_CLKOUT, &npcm8xx_muxes[8].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_CLKOUT }, > + { NPCM8XX_CLKDIV2, 13, 3, NPCM8XX_CLK_S_GFX, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_GFX }, > + { NPCM8XX_CLKDIV2, 8, 5, NPCM8XX_CLK_S_USB_BRIDGE, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU }, Just put the string where there are any macros that are used once please. > + { NPCM8XX_CLKDIV2, 4, 4, NPCM8XX_CLK_S_USB_HOST, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU48 }, > + { NPCM8XX_CLKDIV2, 0, 4, NPCM8XX_CLK_S_SDHC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SDHC }, > + > + { NPCM8XX_CLKDIV3, 16, 8, NPCM8XX_CLK_S_SPI1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI1 }, > + { NPCM8XX_CLKDIV3, 11, 5, NPCM8XX_CLK_S_UART2, &npcm8xx_muxes[3].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_UART2 }, > + { NPCM8XX_CLKDIV3, 6, 5, NPCM8XX_CLK_S_SPI0, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI0 }, > + { NPCM8XX_CLKDIV3, 1, 5, NPCM8XX_CLK_S_SPIX, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPIX }, > + > + { NPCM8XX_CLKDIV4, 28, 4, NPCM8XX_CLK_S_RG, &npcm8xx_muxes[11].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RG }, > + { NPCM8XX_CLKDIV4, 12, 4, NPCM8XX_CLK_S_RCP, &npcm8xx_muxes[12].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RCP }, > + > + { NPCM8XX_THRTL_CNT, 0, 2, NPCM8XX_CLK_S_TH, &npcm8xx_muxes[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_TH }, > +}; > + [...] > + > +static int npcm8xx_clk_probe(struct platform_device *pdev) > +{ > + struct clk_hw_onecell_data *npcm8xx_clk_data; > + struct device_node *np = pdev->dev.of_node; > + struct device *dev = &pdev->dev; > + struct regmap *clk_regmap; > + struct clk_hw *hw; > + unsigned int i; > + > + npcm8xx_clk_data = devm_kzalloc(dev, struct_size(npcm8xx_clk_data, hws, > + NPCM8XX_NUM_CLOCKS), > + GFP_KERNEL); > + if (!npcm8xx_clk_data) > + return -ENOMEM; > + > + clk_regmap = syscon_regmap_lookup_by_phandle(np, "nuvoton,sysclk"); I don't see this as part of the binding either. Please update the binding. > + if (IS_ERR(clk_regmap)) { > + dev_err(&pdev->dev, "Failed to find nuvoton,sysclk\n"); > + return PTR_ERR(clk_regmap); > + } > + > + npcm8xx_clk_data->num = NPCM8XX_NUM_CLOCKS; > + > + for (i = 0; i < NPCM8XX_NUM_CLOCKS; i++) > + npcm8xx_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); > + > + /* Register plls */ From andrew at codeconstruct.com.au Thu Dec 21 09:44:06 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Thu, 21 Dec 2023 09:14:06 +1030 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> Message-ID: On Wed, 2023-12-20 at 15:18 +0100, Ambrozewicz, Adrian wrote: > I would like to apologize for this issue. > > We were undergoing serious reorganization recently and this indeed flew > under the radar. No worries, thanks for responding. As mentioned, it might be a good time to assess whether there are others in the OpenBMC community with an interest in helping maintain the telemetry repo, as it seems to have a heavy dependence on Intel :) Andrew From andrew at codeconstruct.com.au Thu Dec 21 09:58:06 2023 From: andrew at codeconstruct.com.au (Andrew Jeffery) Date: Thu, 21 Dec 2023 09:28:06 +1030 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> Message-ID: <508682f0a990cbc8f34121d8b891c1ee9f934dd7.camel@codeconstruct.com.au> On Wed, 2023-12-20 at 10:56 -0600, Patrick Williams wrote: > My gripe is that you should not be holding up the open-source project for > your own unpublished, undocumented, non-aligned tests. My understanding is now that Adrian is aware of the patches he is doing some of his own testing to build confidence in merging them. *That* latency should probably be measured from around the time I sent the initial email, as I suspect that's when he became aware of the patches. So far that's a few days, which isn't unreasonable to me. As a contributor I sympathise with measuring from when you pushed the patches for review, and that this seems like yet more delay, but hopefully we can separate out the events here. I'd be more concerned about a knee-jerk merge due to getting a mildly stern email and having the merge breaking things. The fact that he's testing them to build his confidence seems like reasonable maintainer practice to me. The fact that it's felt that tests are required in addition to the automated testing is a concern, but I wouldn't yet class this effort as "holding things up" in a tar-pit sense. Andrew From patrick at stwcx.xyz Thu Dec 21 12:54:00 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Wed, 20 Dec 2023 19:54:00 -0600 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: <508682f0a990cbc8f34121d8b891c1ee9f934dd7.camel@codeconstruct.com.au> References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> <508682f0a990cbc8f34121d8b891c1ee9f934dd7.camel@codeconstruct.com.au> Message-ID: On Thu, Dec 21, 2023 at 09:28:06AM +1030, Andrew Jeffery wrote: > On Wed, 2023-12-20 at 10:56 -0600, Patrick Williams wrote: > > My gripe is that you should not be holding up the open-source project for > > your own unpublished, undocumented, non-aligned tests. > > My understanding is now that Adrian is aware of the patches he is doing > some of his own testing to build confidence in merging them. *That* > latency should probably be measured from around the time I sent the > initial email, as I suspect that's when he became aware of the patches. > So far that's a few days, which isn't unreasonable to me. As a > contributor I sympathise with measuring from when you pushed the > patches for review, and that this seems like yet more delay, but > hopefully we can separate out the events here. My concern is not about these specific commits and the timelines on getting them merged. My concern is on the general concept of secret automated tests and/or maintainer-intensive "test driving" of every code change. I've seen a few other maintainers say something similar of "this code tested fine on my system", so this isn't a one-off. Don't read this as I don't want people testing code, but, especially for trivial changes, I don't think we should be constraining the review and merge process by separate "test driving". If that is an expectation I can see why nobody wants to be a maintainer... Even still, I have no idea what the process is if any code fails the maintainer's "test driving". Can I become a maintainer of any repository and require testing on my super-secret hardware before merge? And if it fails, too bad, the code doesn't get merged? (I know this isn't what you're suggesting and I'm being far to one extreme here). I frankly don't see value that this kind of "test driving" is doing for the community other than being a time sink and road block. A big portion of our repositories don't touch hardware enough that they should need any testing on hardware (certainly not openbmc/telemetry in question here). If we can't get sufficient coverage in unit test, something seems missing. If we absolutely need some integration tests, those should go in openbmc-test-automation and aren't even single-repository-dependent. I don't understand what the motivation is for "other testing". > I'd be more concerned about a knee-jerk merge due to getting a mildly > stern email and having the merge breaking things. The fact that he's > testing them to build his confidence seems like reasonable maintainer > practice to me. The fact that it's felt that tests are required in > addition to the automated testing is a concern, but I wouldn't yet > class this effort as "holding things up" in a tar-pit sense. > > Andrew -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From jim.t90615 at gmail.com Thu Dec 21 17:27:13 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Thu, 21 Dec 2023 14:27:13 +0800 Subject: [PATCH v9 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-4-jim.t90615@gmail.com> Message-ID: Hi Andy Thanks for your comments. I will modify it in the next version. But some description as below > > +static int npcm_sgpio_init_port(struct npcm_sgpio *gpio) > > +{ > > + u8 in_port, out_port, set_port, reg; > > + > > + in_port = GPIO_BANK(gpio->nin_sgpio); > > + if (GPIO_BIT(gpio->nin_sgpio) > 0) > > + in_port += 1; > > This is strange... So, you are telling that offsets start from 1 and not 0? > > > + out_port = GPIO_BANK(gpio->nout_sgpio); > > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > > + out_port += 1; > > Ditto. > Yes, if the customer has defined the in/out pins the offsets start from 1. The NPCM_IOXCFG2_PORT register is the set number of in/out ports. NPCM_IOXCFG2_PORT register define as below: 0~3 bit is the number of input ports 4~7 bit is the number of output ports Each module can support 8 input ports and 8 output ports. > ... > > > + set_port = ((out_port & NPCM_IOXCFG2_PORT) << 4) | (in_port & NPCM_IOXCFG2_PORT); > > Outer parentheses are redundant. > > ... > Best regards, Jim From adrian.ambrozewicz at linux.intel.com Thu Dec 21 20:12:17 2023 From: adrian.ambrozewicz at linux.intel.com (Ambrozewicz, Adrian) Date: Thu, 21 Dec 2023 10:12:17 +0100 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: <508682f0a990cbc8f34121d8b891c1ee9f934dd7.camel@codeconstruct.com.au> References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> <508682f0a990cbc8f34121d8b891c1ee9f934dd7.camel@codeconstruct.com.au> Message-ID: <10cd8a0c-4171-43ce-95a4-3b67b775e68d@linux.intel.com> On 20.12.2023 23:58, Andrew Jeffery wrote: > On Wed, 2023-12-20 at 10:56 -0600, Patrick Williams wrote: >> My gripe is that you should not be holding up the open-source project for >> your own unpublished, undocumented, non-aligned tests. > > My understanding is now that Adrian is aware of the patches he is doing > some of his own testing to build confidence in merging them. *That* > latency should probably be measured from around the time I sent the > initial email, as I suspect that's when he became aware of the patches. > So far that's a few days, which isn't unreasonable to me. As a > contributor I sympathise with measuring from when you pushed the > patches for review, and that this seems like yet more delay, but > hopefully we can separate out the events here. > > I'd be more concerned about a knee-jerk merge due to getting a mildly > stern email and having the merge breaking things. The fact that he's > testing them to build his confidence seems like reasonable maintainer > practice to me. Thank you for your consideration. > The fact that it's felt that tests are required in > addition to the automated testing is a concern, but I wouldn't yet > class this effort as "holding things up" in a tar-pit sense. I agree that treating all incoming changes as a package to be tested might be an overkill. I'm just cautious about switching to C++23, and wanted to confirm on target arch and toolchain. Perhaps for some folks here it can be seen as unnecessary, for which I apologize, still beg for pardon :) Regards, Adrian From adrian.ambrozewicz at linux.intel.com Thu Dec 21 21:42:52 2023 From: adrian.ambrozewicz at linux.intel.com (Ambrozewicz, Adrian) Date: Thu, 21 Dec 2023 11:42:52 +0100 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> Message-ID: <74ad915f-02b3-4c69-ab27-472bb9332388@linux.intel.com> On 20.12.2023 17:56, Patrick Williams wrote: > On Wed, Dec 20, 2023 at 05:03:21PM +0100, Ambrozewicz, Adrian wrote: >> What I mean are functional tests on target, with real BMC, board, and >> sensors. > > openbmc/telemetry doesn't interact with any of these things directly. > sensors are covered by dbus-sensors, etc. > > What you are describing is an integration test that belongs in > openbmc-test-automation with all the other integration / functional > tests. > > If you want to make sure that openbmc/telemetry reacts to the dbus model > correctly (which is the only thing that belongs in a repository-level > test) you should mock that out as a unit test. Agreed and this is done in unit tests. >> Could you point me to examples where it's documented or done in >> automated CI for other subprojects? > > See openbmc-test-automation test cases that currently run on QEMU as part of > Romulus and you can talk to Andrew about the hardware tests that run on > Witherspoon (which are non-blocking but he keeps on top of the > failure reports). > Thanks. >> Or perhaps do you meen that maintainer stalling the change until he >> makes sure it doesn't break various configurations is unacceptable? Then >> IMHO I won't aggree, as code compiled within unit tests is just one >> arch, yet alone separated from rest of the system. > > There are many problems with your position from an open source > perspective. These are the ones that are top of mind to me: > > 1. You have no idea if the breakage is due to the submitters proposed > change or because of a change in another repository. Nobody said that tests results are going to be a blind go/no go. That's not the case. > 2. You've made up your own test framework that nobody else has > visibility to. That means you're effectively treating > openbmc/telemetry as your own sandbox and are not collaborating with > the rest of the project. That's a bit harsh statement, considering years of development put into the code itself and contributions made by team in other related areas (sensors, entity-manager, sdbusplus etc.). > 3. Your delay in integrating changes can have velocity impacts to the > rest of the project when we _require_ repository-level changes in > order to integrate a Yocto update, etc. Like Andrew stated - this is an really nasty edge case, a total f-up on our side. I believe delay caused by our plain oversight is than how we assess changes before merging. I could be running my own instance of static analysis tool paid from my pocket for all I care. Does it mean it's wrong? We also strive to shorten the timelines but quality comes first. > 4. Your position is that you will reject someone's commit because it > breaks your internal test. They have no visibility to this test, > they have no way to know that they are "breaking you", and they have > no possible course of action to recover from any issue you report. This is similar to #1 and I don't agree - I've never stated that. You're talking to a guy who often debugs _and_ fixes external bug himself while root-causing. We're on the same side! > If you want to have your own tests to test integration of > openbmc/telemetry (along with other open source components) with your own > project you are more than welcome to do that (even though I think it would be > far more beneficial to enhance openbmc-test-automation). That should > probably be happening when you import openbmc/openbmc into your own > internal tree, but if you want to give yourself early signal to these > failures, that is okay. > > My gripe is that you should not be holding up the open-source project for > your own unpublished, undocumented, non-aligned tests. I see your point and understand your concerns. Thanks for pointing out clearly your arguments. I would prefer to not dwell into further discussion here as certain topics are far beyond my control. I'll just assure you we're trying to do the best we can with resources available. Whenever similar related issues or decisions to make arise in the future I will be surely better equipped to make informed decisions aligned with general open source consensus. Regards, Adrian >> W dniu 20.12.2023 o?16:22, Patrick Williams pisze: >>> On Wed, Dec 20, 2023 at 03:18:38PM +0100, Ambrozewicz, Adrian wrote: >>>> >>>> Currently we've integrated proposed changes and wait for feedback from >>>> automated regression test suite. >>> >>> Hi Adrian, >>> >>> What did you mean by this? Commits go through CI when they are >>> submitted. I don't see any change in Gerrit for any of the 3 commits. >>> >>> If you have an internal test suite you haven't contributed upstream and you >>> are holding off merging commits until you run them through a private test suite, >>> this is unacceptable for the open source project. >>> > From tmaimon77 at gmail.com Fri Dec 22 00:43:20 2023 From: tmaimon77 at gmail.com (Tomer Maimon) Date: Thu, 21 Dec 2023 15:43:20 +0200 Subject: [PATCH RESEND v21] clk: npcm8xx: add clock controller In-Reply-To: <7c322ab2ab59b434429ce471c148c026.sboyd@kernel.org> References: <20231218170404.910153-1-tmaimon77@gmail.com> <7c322ab2ab59b434429ce471c148c026.sboyd@kernel.org> Message-ID: Hi Stephen, Thanks for your comments On Thu, 21 Dec 2023 at 00:09, Stephen Boyd wrote: > > Quoting Tomer Maimon (2023-12-18 09:04:04) > > diff --git a/drivers/clk/clk-npcm8xx.c b/drivers/clk/clk-npcm8xx.c > > new file mode 100644 > > index 000000000000..e6c5111cc255 > > --- /dev/null > > +++ b/drivers/clk/clk-npcm8xx.c > > @@ -0,0 +1,552 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Nuvoton NPCM8xx Clock Generator > > + * All the clocks are initialized by the bootloader, so this driver allows only > > + * reading of current settings directly from the hardware. > > + * > > + * Copyright (C) 2020 Nuvoton Technologies > > + * Author: Tomer Maimon > > + */ > > + > > +#define pr_fmt(fmt) "npcm8xx_clk: " fmt > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > [...] > > +#define NPCM8XX_CLK_S_CLKOUT "clkout" > > +#define NPCM8XX_CLK_S_PRE_ADC "pre adc" > > +#define NPCM8XX_CLK_S_UART "uart" > > +#define NPCM8XX_CLK_S_UART2 "uart2" > > +#define NPCM8XX_CLK_S_TIMER "timer" > > +#define NPCM8XX_CLK_S_MMC "mmc" > > +#define NPCM8XX_CLK_S_SDHC "sdhc" > > +#define NPCM8XX_CLK_S_ADC "adc" > > +#define NPCM8XX_CLK_S_GFX "gfx0_gfx1_mem" > > +#define NPCM8XX_CLK_S_USBIF "serial_usbif" > > +#define NPCM8XX_CLK_S_USB_HOST "usb_host" > > +#define NPCM8XX_CLK_S_USB_BRIDGE "usb_bridge" > > +#define NPCM8XX_CLK_S_PCI "pci" > > +#define NPCM8XX_CLK_S_TH "th" > > +#define NPCM8XX_CLK_S_ATB "atb" > > +#define NPCM8XX_CLK_S_PRE_CLK "pre_clk" > > +#define NPCM8XX_CLK_S_RG "rg" > > +#define NPCM8XX_CLK_S_RCP "rcp" > > + > > +static struct clk_hw hw_pll1_div2, hw_pll2_div2, hw_gfx_div2, hw_pre_clk; > > +static struct npcm8xx_clk_pll_data npcm8xx_pll_clks[] = { > > + { NPCM8XX_CLK_S_PLL0, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON0, 0 }, > > This is a new driver, so please stop using .name in clk_parent_data > structures. A few versions ago you suggested defining the reference clock in the device tree,Can I use .fw_name since the reference clock in the device tree refclk: refclk-25mhz { compatible = "fixed-clock"; clock-output-names = "refclk"; clock-frequency = <25000000>; #clock-cells = <0>; }; clk: clock-controller at f0801000 { compatible = "nuvoton,npcm845-clk"; nuvoton,sysclk = <&rst>; #clock-cells = <1>; clocks = <&refclk>; clock-names = "refclk"; }; I will make sure to add refclk-25mhz to NPCM8xx device tree. > > > + { NPCM8XX_CLK_S_PLL1, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON1, 0 }, > > + { NPCM8XX_CLK_S_PLL2, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCON2, 0 }, > > + { NPCM8XX_CLK_S_PLL_GFX, { .name = NPCM8XX_CLK_S_REFCLK }, NPCM8XX_PLLCONG, 0 }, > > +}; > > + > > +static const u32 cpuck_mux_table[] = { 0, 1, 2, 7 }; > > +static const struct clk_parent_data cpuck_mux_parents[] = { > > + { .hw = &npcm8xx_pll_clks[0].hw }, > > + { .hw = &npcm8xx_pll_clks[1].hw }, > > + { .index = 0 }, > > This requires a binding update. As of today, there isn't a 'clocks' > property for the nuvoton,npcm845-clk binding. Can I use fw_name = NPCM8XX_CLK_S_REFCLK instead of .index = 0 in that way, I will not need to modify nuvoton,npcm845-clk binding. > > > + { .hw = &npcm8xx_pll_clks[2].hw } > > +}; > > + > > +static const u32 pixcksel_mux_table[] = { 0, 2 }; > > +static const struct clk_parent_data pixcksel_mux_parents[] = { > > + { .hw = &npcm8xx_pll_clks[3].hw }, > > + { .index = 0 } > > +}; > > + > [...] > > + > > +/* configurable dividers: */ > > +static struct npcm8xx_clk_div_data npcm8xx_divs[] = { > > + { NPCM8XX_CLKDIV1, 28, 3, NPCM8XX_CLK_S_ADC, &npcm8xx_pre_divs[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_ADC }, > > + { NPCM8XX_CLKDIV1, 16, 5, NPCM8XX_CLK_S_UART, &npcm8xx_muxes[3].hw, 0, 0, NPCM8XX_CLK_UART }, > > + { NPCM8XX_CLKDIV1, 11, 5, NPCM8XX_CLK_S_MMC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_MMC }, > > + { NPCM8XX_CLKDIV1, 6, 5, NPCM8XX_CLK_S_SPI3, &npcm8xx_pre_divs[1].hw, 0, 0, NPCM8XX_CLK_SPI3 }, > > + { NPCM8XX_CLKDIV1, 2, 4, NPCM8XX_CLK_S_PCI, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_PCI }, > > + > > + { NPCM8XX_CLKDIV2, 30, 2, NPCM8XX_CLK_S_APB4, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB4 }, > > + { NPCM8XX_CLKDIV2, 28, 2, NPCM8XX_CLK_S_APB3, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB3 }, > > + { NPCM8XX_CLKDIV2, 26, 2, NPCM8XX_CLK_S_APB2, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB2 }, > > + { NPCM8XX_CLKDIV2, 24, 2, NPCM8XX_CLK_S_APB1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB1 }, > > + { NPCM8XX_CLKDIV2, 22, 2, NPCM8XX_CLK_S_APB5, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_APB5 }, > > + { NPCM8XX_CLKDIV2, 16, 5, NPCM8XX_CLK_S_CLKOUT, &npcm8xx_muxes[8].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_CLKOUT }, > > + { NPCM8XX_CLKDIV2, 13, 3, NPCM8XX_CLK_S_GFX, &npcm8xx_muxes[7].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_GFX }, > > + { NPCM8XX_CLKDIV2, 8, 5, NPCM8XX_CLK_S_USB_BRIDGE, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU }, > > Just put the string where there are any macros that are used once > please. O.K. > > > + { NPCM8XX_CLKDIV2, 4, 4, NPCM8XX_CLK_S_USB_HOST, &npcm8xx_muxes[4].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SU48 }, > > + { NPCM8XX_CLKDIV2, 0, 4, NPCM8XX_CLK_S_SDHC, &npcm8xx_muxes[2].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SDHC }, > > + > > + { NPCM8XX_CLKDIV3, 16, 8, NPCM8XX_CLK_S_SPI1, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI1 }, > > + { NPCM8XX_CLKDIV3, 11, 5, NPCM8XX_CLK_S_UART2, &npcm8xx_muxes[3].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_UART2 }, > > + { NPCM8XX_CLKDIV3, 6, 5, NPCM8XX_CLK_S_SPI0, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPI0 }, > > + { NPCM8XX_CLKDIV3, 1, 5, NPCM8XX_CLK_S_SPIX, &npcm8xx_pre_divs[1].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_SPIX }, > > + > > + { NPCM8XX_CLKDIV4, 28, 4, NPCM8XX_CLK_S_RG, &npcm8xx_muxes[11].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RG }, > > + { NPCM8XX_CLKDIV4, 12, 4, NPCM8XX_CLK_S_RCP, &npcm8xx_muxes[12].hw, CLK_DIVIDER_READ_ONLY, 0, NPCM8XX_CLK_RCP }, > > + > > + { NPCM8XX_THRTL_CNT, 0, 2, NPCM8XX_CLK_S_TH, &npcm8xx_muxes[0].hw, CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_POWER_OF_TWO, 0, NPCM8XX_CLK_TH }, > > +}; > > + > [...] > > + > > +static int npcm8xx_clk_probe(struct platform_device *pdev) > > +{ > > + struct clk_hw_onecell_data *npcm8xx_clk_data; > > + struct device_node *np = pdev->dev.of_node; > > + struct device *dev = &pdev->dev; > > + struct regmap *clk_regmap; > > + struct clk_hw *hw; > > + unsigned int i; > > + > > + npcm8xx_clk_data = devm_kzalloc(dev, struct_size(npcm8xx_clk_data, hws, > > + NPCM8XX_NUM_CLOCKS), > > + GFP_KERNEL); > > + if (!npcm8xx_clk_data) > > + return -ENOMEM; > > + > > + clk_regmap = syscon_regmap_lookup_by_phandle(np, "nuvoton,sysclk"); > > I don't see this as part of the binding either. Please update the > binding. O.K. > > > + if (IS_ERR(clk_regmap)) { > > + dev_err(&pdev->dev, "Failed to find nuvoton,sysclk\n"); > > + return PTR_ERR(clk_regmap); > > + } > > + > > + npcm8xx_clk_data->num = NPCM8XX_NUM_CLOCKS; > > + > > + for (i = 0; i < NPCM8XX_NUM_CLOCKS; i++) > > + npcm8xx_clk_data->hws[i] = ERR_PTR(-EPROBE_DEFER); > > + > > + /* Register plls */ Best regards, Tomer From andy at kernel.org Fri Dec 22 03:28:43 2023 From: andy at kernel.org (Andy Shevchenko) Date: Thu, 21 Dec 2023 18:28:43 +0200 Subject: [PATCH v9 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-4-jim.t90615@gmail.com> Message-ID: On Thu, Dec 21, 2023 at 02:27:13PM +0800, Jim Liu wrote: ... > > > + in_port = GPIO_BANK(gpio->nin_sgpio); > > > + if (GPIO_BIT(gpio->nin_sgpio) > 0) > > > + in_port += 1; > > > > This is strange... So, you are telling that offsets start from 1 and not 0? > > > > > + out_port = GPIO_BANK(gpio->nout_sgpio); > > > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > > > + out_port += 1; > > > > Ditto. > > > Yes, if the customer has defined the in/out pins the offsets start from 1. Why? > The NPCM_IOXCFG2_PORT register is the set number of in/out ports. > NPCM_IOXCFG2_PORT register define as below: > 0~3 bit is the number of input ports > 4~7 bit is the number of output ports > Each module can support 8 input ports and 8 output ports. Right, this doesn't answer why. -- With Best Regards, Andy Shevchenko From jim.t90615 at gmail.com Fri Dec 22 12:27:39 2023 From: jim.t90615 at gmail.com (Jim Liu) Date: Fri, 22 Dec 2023 09:27:39 +0800 Subject: [PATCH v9 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: References: <20231212065147.3475413-1-jim.t90615@gmail.com> <20231212065147.3475413-4-jim.t90615@gmail.com> Message-ID: Hi Andy Thanks for your reply. The description as below > > > + in_port = GPIO_BANK(gpio->nin_sgpio); > > > + if (GPIO_BIT(gpio->nin_sgpio) > 0) > > > + in_port += 1; > > > > This is strange... So, you are telling that offsets start from 1 and not 0? > > > > > + out_port = GPIO_BANK(gpio->nout_sgpio); > > > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > > > + out_port += 1; > > > > Ditto. > > > Yes, if the customer has defined the in/out pins the offsets start from 1. >Why? The NPCM_IOXCFG2_PORT default setting is to enable 0 input port and 0 output port. The register default value is 0x0. Each port can support 8 pins. If the register value is 0x31 means enable 3 output ports and 1 input port. If customer has define nuvoton,input-ngpios or nuvoton,output-ngpios dts property For example , nuvoton,output-ngpios = <9> > > > + out_port = GPIO_BANK(gpio->nout_sgpio); The out_port value is 1 but one port only supports 8 pins. > > > + if (GPIO_BIT(gpio->nout_sgpio) > 0) > > > + out_port += 1; This out_port value is 2, the driver will enable two port to support 9 pins. Maybe it is my expression error , the out_port and in_port default value is 0. > The NPCM_IOXCFG2_PORT register is the set number of in/out ports. > NPCM_IOXCFG2_PORT register define as below: > 0~3 bit is the number of input ports > 4~7 bit is the number of output ports > Each module can support 8 input ports and 8 output ports. Best regards, Jim From patrick at stwcx.xyz Sat Dec 23 08:40:43 2023 From: patrick at stwcx.xyz (Patrick Williams) Date: Fri, 22 Dec 2023 15:40:43 -0600 Subject: openbmc/telemetry: First complaint of unresponsiveness In-Reply-To: <74ad915f-02b3-4c69-ab27-472bb9332388@linux.intel.com> References: <47c53da80f585dac8e1450b20c5855ede960d243.camel@codeconstruct.com.au> <5296a763-9a24-4828-a648-2de5d78cad76@linux.intel.com> <74ad915f-02b3-4c69-ab27-472bb9332388@linux.intel.com> Message-ID: On Thu, Dec 21, 2023 at 11:42:52AM +0100, Ambrozewicz, Adrian wrote: > On 20.12.2023 17:56, Patrick Williams wrote: > > On Wed, Dec 20, 2023 at 05:03:21PM +0100, Ambrozewicz, Adrian wrote: > I would prefer to not dwell into further discussion here as certain > topics are far beyond my control. I'll just assure you we're trying to > do the best we can with resources available. Whenever similar related > issues or decisions to make arise in the future I will be surely better > equipped to make informed decisions aligned with general open source > consensus. Ack. -- Patrick Williams -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: From rdunlap at infradead.org Sat Dec 23 16:06:05 2023 From: rdunlap at infradead.org (Randy Dunlap) Date: Fri, 22 Dec 2023 21:06:05 -0800 Subject: [PATCH] peci: linux/peci.h: fix Excess kernel-doc description warning Message-ID: <20231223050605.13961-1-rdunlap@infradead.org> Remove the @controller: line to prevent the kernel-doc warning: include/linux/peci.h:84: warning: Excess struct member 'controller' description in 'peci_device' Signed-off-by: Randy Dunlap Cc: Iwona Winiarska Cc: openbmc at lists.ozlabs.org --- include/linux/peci.h | 1 - 1 file changed, 1 deletion(-) diff -- a/include/linux/peci.h b/include/linux/peci.h --- a/include/linux/peci.h +++ b/include/linux/peci.h @@ -58,7 +58,6 @@ static inline struct peci_controller *to /** * struct peci_device - PECI device * @dev: device object to register PECI device to the device model - * @controller: manages the bus segment hosting this PECI device * @info: PECI device characteristics * @info.family: device family * @info.model: device model From jim.t90615 at gmail.com Fri Dec 29 18:45:05 2023 From: jim.t90615 at gmail.com (jim.t90615 at gmail.com) Date: Fri, 29 Dec 2023 15:45:05 +0800 Subject: [PATCH v10 0/3] Add Nuvoton NPCM SGPIO feature Message-ID: <20231229074508.2709093-1-JJLIU0@nuvoton.com> From: Jim Liu This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). NPCM7xx/NPCM8xx have two sgpio module each module can support up to 64 output pins,and up to 64 input pin, the pin is only for GPI or GPO. Jim Liu (3): dt-bindings: gpio: add NPCM sgpio driver bindings arm: dts: nuvoton: npcm: Add sgpio feature gpio: nuvoton: Add Nuvoton NPCM sgpio driver .../bindings/gpio/nuvoton,sgpio.yaml | 87 +++ .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 + drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 612 ++++++++++++++++++ 5 files changed, 731 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml create mode 100644 drivers/gpio/gpio-npcm-sgpio.c -- 2.25.1 From jim.t90615 at gmail.com Fri Dec 29 18:45:06 2023 From: jim.t90615 at gmail.com (jim.t90615 at gmail.com) Date: Fri, 29 Dec 2023 15:45:06 +0800 Subject: [PATCH v10 1/3] dt-bindings: gpio: add NPCM sgpio driver bindings In-Reply-To: <20231229074508.2709093-1-JJLIU0@nuvoton.com> References: <20231229074508.2709093-1-JJLIU0@nuvoton.com> Message-ID: <20231229074508.2709093-2-JJLIU0@nuvoton.com> From: Jim Liu Add dt-bindings document for the Nuvoton NPCM7xx sgpio driver Signed-off-by: Jim Liu Reviewed-by: Linus Walleij Reviewed-by: Rob Herring Reviewed-by: Paul Menzel --- Changes for v10: - modify error words Changes for v9: - no changed Changes for v8: - no changed --- .../bindings/gpio/nuvoton,sgpio.yaml | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml diff --git a/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml new file mode 100644 index 000000000000..9e32e54aeb24 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/nuvoton,sgpio.yaml @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/nuvoton,sgpio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton SGPIO controller + +maintainers: + - Jim LIU + +description: | + This SGPIO controller is for NUVOTON NPCM7xx and NPCM8xx SoC and detailed + information is in the NPCM7XX/8XX SERIAL I/O EXPANSION INTERFACE section. + Nuvoton NPCM7xx SGPIO module is combines a serial to parallel IC (HC595) + and a parallel to serial IC (HC165). + Clock is a division of the APB3 clock. + This interface has 4 pins (D_out , D_in, S_CLK, LDSH). + NPCM7xx/NPCM8xx have two sgpio modules. Each module can support up + to 64 output pins, and up to 64 input pins, the pin is only for GPI or GPO. + GPIO pins can be programmed to support the following options + - Support interrupt option for each input port and various interrupt + sensitivity options (level-high, level-low, edge-high, edge-low) + - ngpios is number of nuvoton,input-ngpios GPIO lines and nuvoton,output-ngpios GPIO lines. + nuvoton,input-ngpios GPIO lines is only for GPI. + nuvoton,output-ngpios GPIO lines is only for GPO. + +properties: + compatible: + enum: + - nuvoton,npcm750-sgpio + - nuvoton,npcm845-sgpio + + reg: + maxItems: 1 + + gpio-controller: true + + '#gpio-cells': + const: 2 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + nuvoton,input-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines are only for GPI. + minimum: 0 + maximum: 64 + + nuvoton,output-ngpios: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + The numbers of GPIO's exposed. GPIO lines are only for GPO. + minimum: 0 + maximum: 64 + +required: + - compatible + - reg + - gpio-controller + - '#gpio-cells' + - interrupts + - nuvoton,input-ngpios + - nuvoton,output-ngpios + - clocks + +additionalProperties: false + +examples: + - | + #include + #include + gpio8: gpio at 101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + }; -- 2.25.1 From jim.t90615 at gmail.com Fri Dec 29 18:45:07 2023 From: jim.t90615 at gmail.com (jim.t90615 at gmail.com) Date: Fri, 29 Dec 2023 15:45:07 +0800 Subject: [PATCH v10 2/3] arm: dts: nuvoton: npcm: Add sgpio feature In-Reply-To: <20231229074508.2709093-1-JJLIU0@nuvoton.com> References: <20231229074508.2709093-1-JJLIU0@nuvoton.com> Message-ID: <20231229074508.2709093-3-JJLIU0@nuvoton.com> From: Jim Liu Add the SGPIO controller to the NPCM7xx devicetree Signed-off-by: Jim Liu --- Changes for v10: - no changed Changes for v9: - no changed --- .../dts/nuvoton/nuvoton-common-npcm7xx.dtsi | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi b/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi index 868454ae6bde..df91517a4842 100644 --- a/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi +++ b/arch/arm/boot/dts/nuvoton/nuvoton-common-npcm7xx.dtsi @@ -372,6 +372,30 @@ &fanin12_pins &fanin13_pins status = "disabled"; }; + gpio8: gpio at 101000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x101000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + + gpio9: gpio at 102000 { + compatible = "nuvoton,npcm750-sgpio"; + reg = <0x102000 0x200>; + clocks = <&clk NPCM7XX_CLK_APB3>; + interrupts = ; + gpio-controller; + #gpio-cells = <2>; + nuvoton,input-ngpios = <64>; + nuvoton,output-ngpios = <64>; + status = "disabled"; + }; + i2c0: i2c at 80000 { reg = <0x80000 0x1000>; compatible = "nuvoton,npcm750-i2c"; -- 2.25.1 From jim.t90615 at gmail.com Fri Dec 29 18:45:08 2023 From: jim.t90615 at gmail.com (jim.t90615 at gmail.com) Date: Fri, 29 Dec 2023 15:45:08 +0800 Subject: [PATCH v10 3/3] gpio: nuvoton: Add Nuvoton NPCM sgpio driver In-Reply-To: <20231229074508.2709093-1-JJLIU0@nuvoton.com> References: <20231229074508.2709093-1-JJLIU0@nuvoton.com> Message-ID: <20231229074508.2709093-4-JJLIU0@nuvoton.com> From: Jim Liu Add Nuvoton BMC NPCM7xx/NPCM8xx sgpio driver support. Nuvoton NPCM SGPIO module is combine serial to parallel IC (HC595) and parallel to serial IC (HC165), and use APB3 clock to control it. This interface has 4 pins (D_out , D_in, S_CLK, LDSH). BMC can use this driver to increase 64 GPI pins and 64 GPO pins to use. Signed-off-by: Jim Liu --- Changes for v10: - use HZ_PER_MHZ - check blank line and spaces wrongs - use dev_err_probe - Instead of conditionals use arithmetics Changes for v9: - fix kernel rebot test warning Changes for v8: - Remove OF_GPIO/GPIO_GENERIC and redundant assignments - Use GENMASK() and BIT() - Use dev_WARN and dev_err_probe - Check indentation issue - Use raw_spinlock_t --- drivers/gpio/Kconfig | 7 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-npcm-sgpio.c | 612 +++++++++++++++++++++++++++++++++ 3 files changed, 620 insertions(+) create mode 100644 drivers/gpio/gpio-npcm-sgpio.c diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index b3a133ed31ee..efbdc93819d4 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -478,6 +478,13 @@ config GPIO_MXS select GPIO_GENERIC select GENERIC_IRQ_CHIP +config GPIO_NPCM_SGPIO + bool "Nuvoton SGPIO support" + depends on ARCH_NPCM || COMPILE_TEST + select GPIOLIB_IRQCHIP + help + Say Y here to support Nuvoton NPCM7XX/NPCM8XX SGPIO functionality. + config GPIO_OCTEON tristate "Cavium OCTEON GPIO" depends on CAVIUM_OCTEON_SOC diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index eb73b5d633eb..373aa2943de5 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -116,6 +116,7 @@ obj-$(CONFIG_GPIO_MT7621) += gpio-mt7621.o obj-$(CONFIG_GPIO_MVEBU) += gpio-mvebu.o obj-$(CONFIG_GPIO_MXC) += gpio-mxc.o obj-$(CONFIG_GPIO_MXS) += gpio-mxs.o +obj-$(CONFIG_GPIO_NPCM_SGPIO) += gpio-npcm-sgpio.o obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o obj-$(CONFIG_GPIO_OMAP) += gpio-omap.o obj-$(CONFIG_GPIO_PALMAS) += gpio-palmas.o diff --git a/drivers/gpio/gpio-npcm-sgpio.c b/drivers/gpio/gpio-npcm-sgpio.c new file mode 100644 index 000000000000..e9057c4a658d --- /dev/null +++ b/drivers/gpio/gpio-npcm-sgpio.c @@ -0,0 +1,612 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Nuvoton NPCM Serial GPIO Driver + * + * Copyright (C) 2021 Nuvoton Technologies + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_NR_HW_SGPIO 64 + +#define NPCM_IOXCFG1 0x2A +#define NPCM_IOXCFG1_SFT_CLK GENMASK(3, 0) +#define NPCM_IOXCFG1_SCLK_POL BIT(4) +#define NPCM_IOXCFG1_LDSH_POL BIT(5) + +#define NPCM_IOXCTS 0x28 +#define NPCM_IOXCTS_IOXIF_EN BIT(7) +#define NPCM_IOXCTS_RD_MODE GENMASK(2, 1) +#define NPCM_IOXCTS_RD_MODE_PERIODIC BIT(2) + +#define NPCM_IOXCFG2 0x2B +#define NPCM_IOXCFG2_PORT GENMASK(3, 0) + +#define NPCM_IXOEVCFG_MASK GENMASK(1, 0) +#define NPCM_IXOEVCFG_FALLING BIT(1) +#define NPCM_IXOEVCFG_RISING BIT(0) +#define NPCM_IXOEVCFG_BOTH (NPCM_IXOEVCFG_FALLING | NPCM_IXOEVCFG_RISING) + +#define NPCM_CLK_MHZ (8 * HZ_PER_MHZ) +#define NPCM_750_OPT 6 +#define NPCM_845_OPT 5 + +#define GPIO_BANK(x) ((x) / 8) +#define GPIO_BIT(x) ((x) % 8) + +/* + * Select the frequency of shift clock. + * The shift clock is a division of the APB clock. + */ +struct npcm_clk_cfg { + unsigned int *sft_clk; + unsigned int *clk_sel; + unsigned int cfg_opt; +}; + +struct npcm_sgpio { + struct gpio_chip chip; + struct clk *pclk; + struct irq_chip intc; + raw_spinlock_t lock; + + void __iomem *base; + int irq; + u8 nin_sgpio; + u8 nout_sgpio; + u8 in_port; + u8 out_port; + u8 int_type[MAX_NR_HW_SGPIO]; +}; + +struct npcm_sgpio_bank { + u8 rdata_reg; + u8 wdata_reg; + u8 event_config; + u8 event_status; +}; + +enum npcm_sgpio_reg { + READ_DATA, + WRITE_DATA, + EVENT_CFG, + EVENT_STS, +}; + +static const struct npcm_sgpio_bank npcm_sgpio_banks[] = { + { + .wdata_reg = 0x00, + .rdata_reg = 0x08, + .event_config = 0x10, + .event_status = 0x20, + }, + { + .wdata_reg = 0x01, + .rdata_reg = 0x09, + .event_config = 0x12, + .event_status = 0x21, + }, + { + .wdata_reg = 0x02, + .rdata_reg = 0x0a, + .event_config = 0x14, + .event_status = 0x22, + }, + { + .wdata_reg = 0x03, + .rdata_reg = 0x0b, + .event_config = 0x16, + .event_status = 0x23, + }, + { + .wdata_reg = 0x04, + .rdata_reg = 0x0c, + .event_config = 0x18, + .event_status = 0x24, + }, + { + .wdata_reg = 0x05, + .rdata_reg = 0x0d, + .event_config = 0x1a, + .event_status = 0x25, + }, + { + .wdata_reg = 0x06, + .rdata_reg = 0x0e, + .event_config = 0x1c, + .event_status = 0x26, + }, + { + .wdata_reg = 0x07, + .rdata_reg = 0x0f, + .event_config = 0x1e, + .event_status = 0x27, + }, +}; + +static void __iomem *bank_reg(struct npcm_sgpio *gpio, + const struct npcm_sgpio_bank *bank, + const enum npcm_sgpio_reg reg) +{ + switch (reg) { + case READ_DATA: + return gpio->base + bank->rdata_reg; + case WRITE_DATA: + return gpio->base + bank->wdata_reg; + case EVENT_CFG: + return gpio->base + bank->event_config; + case EVENT_STS: + return gpio->base + bank->event_status; + default: + /* actually if code runs to here, it's an error case */ + dev_WARN(gpio->chip.parent, "Getting here is an error condition"); + return NULL; + } +} + +static const struct npcm_sgpio_bank *offset_to_bank(unsigned int offset) +{ + unsigned int bank = GPIO_BANK(offset); + + return &npcm_sgpio_banks[bank]; +} + +static void npcm_sgpio_irqd_to_data(struct irq_data *d, + struct npcm_sgpio **gpio, + const struct npcm_sgpio_bank **bank, + u8 *bit, unsigned int *offset) +{ + struct npcm_sgpio *internal; + + *offset = irqd_to_hwirq(d); + internal = irq_data_get_irq_chip_data(d); + + *gpio = internal; + *offset -= internal->nout_sgpio; + *bank = offset_to_bank(*offset); + *bit = GPIO_BIT(*offset); +} + +static int npcm_sgpio_init_port(struct npcm_sgpio *gpio) +{ + u8 in_port, out_port, set_port, reg; + + in_port = GPIO_BANK(gpio->nin_sgpio); + if (GPIO_BIT(gpio->nin_sgpio) > 0) + in_port += 1; + + out_port = GPIO_BANK(gpio->nout_sgpio); + if (GPIO_BIT(gpio->nout_sgpio) > 0) + out_port += 1; + + gpio->in_port = in_port; + gpio->out_port = out_port; + set_port = (out_port & NPCM_IOXCFG2_PORT) << 4 | (in_port & NPCM_IOXCFG2_PORT); + iowrite8(set_port, gpio->base + NPCM_IOXCFG2); + + reg = ioread8(gpio->base + NPCM_IOXCFG2); + + return reg == set_port ? 0 : -EINVAL; + +} + +static int npcm_sgpio_dir_in(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + return offset < gpio->nout_sgpio ? -EINVAL : 0; + +} + +static int npcm_sgpio_dir_out(struct gpio_chip *gc, unsigned int offset, int val) +{ + gc->set(gc, offset, val); + + return 0; +} + +static int npcm_sgpio_get_direction(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + if (offset < gpio->nout_sgpio) + return GPIO_LINE_DIRECTION_OUT; + + return GPIO_LINE_DIRECTION_IN; +} + +static void npcm_sgpio_set(struct gpio_chip *gc, unsigned int offset, int val) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + const struct npcm_sgpio_bank *bank = offset_to_bank(offset); + void __iomem *addr; + u8 reg = 0; + + addr = bank_reg(gpio, bank, WRITE_DATA); + reg = ioread8(addr); + + if (val) + reg |= BIT(GPIO_BIT(offset)); + else + reg &= ~BIT(GPIO_BIT(offset)); + + iowrite8(reg, addr); +} + +static int npcm_sgpio_get(struct gpio_chip *gc, unsigned int offset) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + const struct npcm_sgpio_bank *bank; + void __iomem *addr; + u8 reg; + + if (offset < gpio->nout_sgpio) { + bank = offset_to_bank(offset); + addr = bank_reg(gpio, bank, WRITE_DATA); + } else { + offset -= gpio->nout_sgpio; + bank = offset_to_bank(offset); + addr = bank_reg(gpio, bank, READ_DATA); + } + + reg = ioread8(addr); + + return !!(reg & BIT(GPIO_BIT(offset))); +} + +static void npcm_sgpio_setup_enable(struct npcm_sgpio *gpio, bool enable) +{ + u8 reg; + + reg = ioread8(gpio->base + NPCM_IOXCTS); + reg = (reg & ~NPCM_IOXCTS_RD_MODE) | NPCM_IOXCTS_RD_MODE_PERIODIC; + + if (enable) + reg |= NPCM_IOXCTS_IOXIF_EN; + else + reg &= ~NPCM_IOXCTS_IOXIF_EN; + + iowrite8(reg, gpio->base + NPCM_IOXCTS); +} + +static int npcm_sgpio_setup_clk(struct npcm_sgpio *gpio, + const struct npcm_clk_cfg *clk_cfg) +{ + unsigned long apb_freq; + u32 val; + u8 tmp; + int i; + + apb_freq = clk_get_rate(gpio->pclk); + tmp = ioread8(gpio->base + NPCM_IOXCFG1) & ~NPCM_IOXCFG1_SFT_CLK; + + for (i = clk_cfg->cfg_opt-1; i > 0; i--) { + val = apb_freq / clk_cfg->sft_clk[i]; + if (NPCM_CLK_MHZ > val) { + iowrite8(clk_cfg->clk_sel[i] | tmp, gpio->base + NPCM_IOXCFG1); + return 0; + } + } + + return -EINVAL; +} + +static void npcm_sgpio_irq_init_valid_mask(struct gpio_chip *gc, + unsigned long *valid_mask, unsigned int ngpios) +{ + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + + /* input GPIOs in the high range */ + bitmap_set(valid_mask, gpio->nout_sgpio, gpio->nin_sgpio); + bitmap_clear(valid_mask, 0, gpio->nout_sgpio); +} + +static void npcm_sgpio_irq_set_mask(struct irq_data *d, bool set) +{ + const struct npcm_sgpio_bank *bank; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *addr; + unsigned int offset; + u16 reg, type; + u8 bit; + + npcm_sgpio_irqd_to_data(d, &gpio, &bank, &bit, &offset); + addr = bank_reg(gpio, bank, EVENT_CFG); + + reg = ioread16(addr); + if (set) { + reg &= ~(NPCM_IXOEVCFG_MASK << (bit * 2)); + } else { + type = gpio->int_type[offset]; + reg |= (type << (bit * 2)); + } + + raw_spin_lock_irqsave(&gpio->lock, flags); + + npcm_sgpio_setup_enable(gpio, false); + + iowrite16(reg, addr); + + npcm_sgpio_setup_enable(gpio, true); + + addr = bank_reg(gpio, bank, EVENT_STS); + reg = ioread8(addr); + reg |= BIT(bit); + iowrite8(reg, addr); + + raw_spin_unlock_irqrestore(&gpio->lock, flags); +} + +static void npcm_sgpio_irq_ack(struct irq_data *d) +{ + const struct npcm_sgpio_bank *bank; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *status_addr; + unsigned int offset; + u8 bit; + + npcm_sgpio_irqd_to_data(d, &gpio, &bank, &bit, &offset); + status_addr = bank_reg(gpio, bank, EVENT_STS); + raw_spin_lock_irqsave(&gpio->lock, flags); + iowrite8(BIT(bit), status_addr); + raw_spin_unlock_irqrestore(&gpio->lock, flags); +} + +static void npcm_sgpio_irq_mask(struct irq_data *d) +{ + npcm_sgpio_irq_set_mask(d, true); +} + +static void npcm_sgpio_irq_unmask(struct irq_data *d) +{ + npcm_sgpio_irq_set_mask(d, false); +} + +static int npcm_sgpio_set_type(struct irq_data *d, unsigned int type) +{ + const struct npcm_sgpio_bank *bank; + irq_flow_handler_t handler; + struct npcm_sgpio *gpio; + unsigned long flags; + void __iomem *addr; + unsigned int offset; + u16 reg, val; + u8 bit; + + npcm_sgpio_irqd_to_data(d, &gpio, &bank, &bit, &offset); + + switch (type & IRQ_TYPE_SENSE_MASK) { + case IRQ_TYPE_EDGE_BOTH: + val = NPCM_IXOEVCFG_BOTH; + break; + case IRQ_TYPE_EDGE_RISING: + case IRQ_TYPE_LEVEL_HIGH: + val = NPCM_IXOEVCFG_RISING; + break; + case IRQ_TYPE_EDGE_FALLING: + case IRQ_TYPE_LEVEL_LOW: + val = NPCM_IXOEVCFG_FALLING; + break; + default: + return -EINVAL; + } + + if (type & IRQ_TYPE_LEVEL_MASK) + handler = handle_level_irq; + else + handler = handle_edge_irq; + + gpio->int_type[offset] = val; + + raw_spin_lock_irqsave(&gpio->lock, flags); + npcm_sgpio_setup_enable(gpio, false); + addr = bank_reg(gpio, bank, EVENT_CFG); + reg = ioread16(addr); + + reg |= (val << (bit * 2)); + + iowrite16(reg, addr); + npcm_sgpio_setup_enable(gpio, true); + raw_spin_unlock_irqrestore(&gpio->lock, flags); + + irq_set_handler_locked(d, handler); + + return 0; +} + +static void npcm_sgpio_irq_handler(struct irq_desc *desc) +{ + struct gpio_chip *gc = irq_desc_get_handler_data(desc); + struct irq_chip *ic = irq_desc_get_chip(desc); + struct npcm_sgpio *gpio = gpiochip_get_data(gc); + unsigned int i, j, girq; + unsigned long reg; + + chained_irq_enter(ic, desc); + + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; + + reg = ioread8(bank_reg(gpio, bank, EVENT_STS)); + for_each_set_bit(j, ®, 8) { + girq = irq_find_mapping(gc->irq.domain, i * 8 + gpio->nout_sgpio + j); + generic_handle_domain_irq(gc->irq.domain, girq); + } + } + + chained_irq_exit(ic, desc); +} + +static const struct irq_chip sgpio_irq_chip = { + .name = "sgpio-irq", + .irq_ack = npcm_sgpio_irq_ack, + .irq_mask = npcm_sgpio_irq_mask, + .irq_unmask = npcm_sgpio_irq_unmask, + .irq_set_type = npcm_sgpio_set_type, + .flags = IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + +static int npcm_sgpio_setup_irqs(struct npcm_sgpio *gpio, + struct platform_device *pdev) +{ + int rc, i; + struct gpio_irq_chip *irq; + + rc = platform_get_irq(pdev, 0); + if (rc < 0) + return rc; + + gpio->irq = rc; + + npcm_sgpio_setup_enable(gpio, false); + + /* Disable IRQ and clear Interrupt status registers for all SGPIO Pins. */ + for (i = 0; i < ARRAY_SIZE(npcm_sgpio_banks); i++) { + const struct npcm_sgpio_bank *bank = &npcm_sgpio_banks[i]; + + iowrite16(0, bank_reg(gpio, bank, EVENT_CFG)); + iowrite8(0xff, bank_reg(gpio, bank, EVENT_STS)); + } + + irq = &gpio->chip.irq; + gpio_irq_chip_set_chip(irq, &sgpio_irq_chip); + irq->init_valid_mask = npcm_sgpio_irq_init_valid_mask; + irq->handler = handle_bad_irq; + irq->default_type = IRQ_TYPE_NONE; + irq->parent_handler = npcm_sgpio_irq_handler; + irq->parent_handler_data = gpio; + irq->parents = &gpio->irq; + irq->num_parents = 1; + + return 0; +} + +static int npcm_sgpio_probe(struct platform_device *pdev) +{ + struct npcm_sgpio *gpio; + const struct npcm_clk_cfg *clk_cfg; + int rc; + u32 nin_gpios, nout_gpios; + + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); + if (!gpio) + return -ENOMEM; + + gpio->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(gpio->base)) + return PTR_ERR(gpio->base); + + clk_cfg = device_get_match_data(&pdev->dev); + if (!clk_cfg) + return -EINVAL; + + rc = device_property_read_u32(&pdev->dev, "nuvoton,input-ngpios", &nin_gpios); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Could not read ngpios property\n"); + + rc = device_property_read_u32(&pdev->dev, "nuvoton,output-ngpios", &nout_gpios); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Could not read ngpios property\n"); + + gpio->nin_sgpio = nin_gpios; + gpio->nout_sgpio = nout_gpios; + if (gpio->nin_sgpio > MAX_NR_HW_SGPIO || gpio->nout_sgpio > MAX_NR_HW_SGPIO) + return dev_err_probe(&pdev->dev, -EINVAL, "Number of GPIOs exceeds the maximum of %d: input: %d output: %d\n", MAX_NR_HW_SGPIO, nin_gpios, nout_gpios); + + gpio->pclk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(gpio->pclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(gpio->pclk), "Could not get pclk\n"); + + rc = npcm_sgpio_setup_clk(gpio, clk_cfg); + if (rc < 0) + return dev_err_probe(&pdev->dev, rc, "Failed to setup clock\n"); + + raw_spin_lock_init(&gpio->lock); + gpio->chip.parent = &pdev->dev; + gpio->chip.ngpio = gpio->nin_sgpio + gpio->nout_sgpio; + gpio->chip.direction_input = npcm_sgpio_dir_in; + gpio->chip.direction_output = npcm_sgpio_dir_out; + gpio->chip.get_direction = npcm_sgpio_get_direction; + gpio->chip.get = npcm_sgpio_get; + gpio->chip.set = npcm_sgpio_set; + gpio->chip.label = dev_name(&pdev->dev); + gpio->chip.base = -1; + + rc = npcm_sgpio_init_port(gpio); + if (rc < 0) + return rc; + + rc = npcm_sgpio_setup_irqs(gpio, pdev); + if (rc < 0) + return rc; + + rc = devm_gpiochip_add_data(&pdev->dev, &gpio->chip, gpio); + if (rc) + return dev_err_probe(&pdev->dev, rc, "GPIO registering failed\n"); + + npcm_sgpio_setup_enable(gpio, true); + + return 0; +} + +static unsigned int npcm750_SFT_CLK[NPCM_750_OPT] = { + 1024, 32, 8, 4, 3, 2, +}; + +static unsigned int npcm750_CLK_SEL[NPCM_750_OPT] = { + 0x00, 0x05, 0x07, 0x0C, 0x0D, 0x0E, +}; + +static unsigned int npcm845_SFT_CLK[NPCM_845_OPT] = { + 1024, 32, 16, 8, 4, +}; + +static unsigned int npcm845_CLK_SEL[NPCM_845_OPT] = { + 0x00, 0x05, 0x06, 0x07, 0x0C, +}; + +static struct npcm_clk_cfg npcm750_sgpio_pdata = { + .sft_clk = npcm750_SFT_CLK, + .clk_sel = npcm750_CLK_SEL, + .cfg_opt = NPCM_750_OPT, +}; + +static const struct npcm_clk_cfg npcm845_sgpio_pdata = { + .sft_clk = npcm845_SFT_CLK, + .clk_sel = npcm845_CLK_SEL, + .cfg_opt = NPCM_845_OPT, +}; + +static const struct of_device_id npcm_sgpio_of_table[] = { + { .compatible = "nuvoton,npcm750-sgpio", .data = &npcm750_sgpio_pdata, }, + { .compatible = "nuvoton,npcm845-sgpio", .data = &npcm845_sgpio_pdata, }, + {} +}; +MODULE_DEVICE_TABLE(of, npcm_sgpio_of_table); + +static struct platform_driver npcm_sgpio_driver = { + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = npcm_sgpio_of_table, + }, + .probe = npcm_sgpio_probe, +}; +module_platform_driver(npcm_sgpio_driver); + +MODULE_AUTHOR("Jim Liu "); +MODULE_AUTHOR("Joseph Liu "); +MODULE_DESCRIPTION("Nuvoton NPCM Serial GPIO Driver"); +MODULE_LICENSE("GPL v2"); -- 2.25.1 From radhaiezhil.murugan at hcl.com Wed Dec 20 17:06:20 2023 From: radhaiezhil.murugan at hcl.com (Radhai Ezhil Murugan) Date: Wed, 20 Dec 2023 06:06:20 +0000 Subject: New User added ,not able to access through LAN with ipmitool lanplus command Message-ID: Hi, I have added new user with administator privilege and ipmi =on D Name Callin Link Auth IPMI Msg Channel Priv Limit 1 root false true true ADMINISTRATOR 2 operator1 true true true ADMINISTRATOR 3 true false false NO ACCESS 4 true false false NO ACCESS 5 true false false NO ACCESS 6 true false false NO ACCESS 7 true false false NO ACCESS 8 true false false NO ACCESS 9 true false false NO ACCESS 10 true false false NO ACCESS 11 true false false NO ACCESS 12 true false false NO ACCESS 13 true false false NO ACCESS 14 true false false NO ACCESS 15 true false false NO ACCESS and acess level for both root user and LAN user are same radhai at radhai-ThinkPad-T495:~$ ipmitool -C 17 -H 192.168.1.211 -I lanplus -U root -P 0penBmc channel getaccess 1 2 Maximum User IDs : 15 Enabled User IDs : 2 User ID : 2 User Name : operator1 Fixed Name : No Access Available : call-in / callback Link Authentication : enabled IPMI Messaging : enabled Privilege Level : ADMINISTRATOR Enable Status : enabled radhai at radhai-ThinkPad-T495:~$ ipmitool -C 17 -H 192.168.1.211 -I lanplus -U root -P 0penBmc channel getaccess 1 1 Maximum User IDs : 15 Enabled User IDs : 2 User ID : 1 User Name : root Fixed Name : No Access Available : callback Link Authentication : enabled IPMI Messaging : enabled Privilege Level : ADMINISTRATOR Enable Status : enabled but new user not able to establish connection with ipmitool lanplus command radhai at radhai-ThinkPad-T495:~$ ipmitool -C 17 -H 192.168.1.211 -I lanplus -U operator1 -P password1234 power status Error: Unable to establish IPMI v2 / RMCP+ session I need establish LAN access for new user Please advise Thank you , Radhai ::DISCLAIMER:: ________________________________ The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. E-mail transmission is not guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or may contain viruses in transmission. The e mail and its contents (with or without referred errors) shall therefore not attach any liability on the originator or HCL or its affiliates. Views or opinions, if any, presented in this email are solely those of the author and may not necessarily reflect the views or opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of authorized representative of HCL is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any email and/or attachments, please check them for viruses and other defects. ________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: From lukas at wunner.de Wed Dec 20 19:14:02 2023 From: lukas at wunner.de (Lukas Wunner) Date: Wed, 20 Dec 2023 09:14:02 +0100 Subject: [PATCH v2 3/6] ARM: dts: aspeed: Common dtsi for Facebook AST2600 Network BMCs In-Reply-To: <20210805222818.8391-4-rentao.bupt@gmail.com> References: <20210805222818.8391-1-rentao.bupt@gmail.com> <20210805222818.8391-4-rentao.bupt@gmail.com> Message-ID: <20231220081402.GA3831@wunner.de> On Thu, Aug 05, 2021 at 03:28:15PM -0700, rentao.bupt at gmail.com wrote: > This common descirption is included by all Facebook AST2600 Network BMC > platforms to minimize duplicated device entries across Facebook Network > BMC device trees. [...] > --- /dev/null > +++ b/arch/arm/boot/dts/ast2600-facebook-netbmc-common.dtsi [...] > + tpmdev at 0 { > + compatible = "tcg,tpm_tis-spi"; What's the chip used on this board? Going forward, the DT schema for TPMs requires the exact chip name in addition to the generic "tcg,tpm_tis-spi". > + spi-max-frequency = <33000000>; > + reg = <0>; > + }; From lukas at wunner.de Wed Dec 20 19:27:14 2023 From: lukas at wunner.de (Lukas Wunner) Date: Wed, 20 Dec 2023 09:27:14 +0100 Subject: [PATCH 5/5] ARM: dts: aspeed: Add Facebook Wedge400 BMC In-Reply-To: <20200824211948.12852-6-rentao.bupt@gmail.com> References: <20200824211948.12852-1-rentao.bupt@gmail.com> <20200824211948.12852-6-rentao.bupt@gmail.com> Message-ID: <20231220082714.GA17989@wunner.de> On Mon, Aug 24, 2020 at 02:19:48PM -0700, rentao.bupt at gmail.com wrote: > Add initial version of device tree for Facebook Wedge400 (AST2500) BMC. [...] > --- /dev/null > +++ b/arch/arm/boot/dts/aspeed-bmc-facebook-wedge400.dts [...] > + tpmdev at 0 { > + compatible = "tcg,tpm_tis-spi"; What's the chip used on this board? Going forward, the DT schema for TPMs requires the exact chip name in addition to the generic "tcg,tpm_tis-spi". > + spi-max-frequency = <33000000>; > + reg = <0>; > + }; From baneric926 at gmail.com Thu Dec 21 11:44:18 2023 From: baneric926 at gmail.com (Ban Feng) Date: Thu, 21 Dec 2023 08:44:18 +0800 Subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <170297774900.1297817.5593278746406765111.robh@kernel.org> References: <20231219080021.2048889-1-kcfeng0@nuvoton.com> <20231219080021.2048889-2-kcfeng0@nuvoton.com> <170297774900.1297817.5593278746406765111.robh@kernel.org> Message-ID: Hi Rob, On Tue, Dec 19, 2023 at 5:22?PM Rob Herring wrote: > > > On Tue, 19 Dec 2023 16:00:20 +0800, baneric926 at gmail.com wrote: > > From: Ban Feng > > > > Adding bindings for the Nuvoton NCT7363Y Fan Controller > > > > Signed-off-by: Ban Feng > > --- > > .../bindings/hwmon/nuvoton,nct7363.yaml | 62 +++++++++++++++++++ > > MAINTAINERS | 6 ++ > > 2 files changed, 68 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml > > > > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' > on your patch (DT_CHECKER_FLAGS is new in v5.13): Our design is based on [1], and adds fan-common.yaml to Documentation/devicetree/bindings/hwmon/, I didn't see any errors when executing dt_binding_check. This design is suggested by reviewer, and [1] is still reviewing: [1]: https://patchwork.kernel.org/project/linux-hwmon/patch/20231107105025.1480561-2-billy_tsai at aspeedtech.com/ How to modify our patch to achieve referencing patch not merged yet? > > yamllint warnings/errors: > > dtschema/dtc warnings/errors: > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml: > Error in referenced schema matching $id: http://devicetree.org/schemas/hwmon/fan-common.yaml > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.example.dtb: hwmon at 22: fan-0: False schema does not allow {'pwms': [[1, 0, 50000]], 'tach-ch': ['']} > from schema $id: http://devicetree.org/schemas/hwmon/nuvoton,nct7363.yaml# > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.example.dtb: hwmon at 22: fan-1: False schema does not allow {'pwms': [[1, 1, 50000]], 'tach-ch': b'\x01'} > from schema $id: http://devicetree.org/schemas/hwmon/nuvoton,nct7363.yaml# > /builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.example.dtb: fan-1: tach-ch: b'\x01' is not of type 'object', 'array', 'boolean', 'null' > from schema $id: http://devicetree.org/schemas/dt-core.yaml# > > doc reference errors (make refcheckdocs): > Warning: MAINTAINERS references a file that doesn't exist: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml > MAINTAINERS: Documentation/devicetree/bindings/hwmon/nuvoton,nct736x.yaml I will modify this typo in v3. Thanks, Ban > > See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20231219080021.2048889-2-kcfeng0 at nuvoton.com > > The base for the series is generally the latest rc1. A different dependency > should be noted in *this* patch. > > If you already ran 'make dt_binding_check' and didn't see the above > error(s), then make sure 'yamllint' is installed and dt-schema is up to > date: > > pip3 install dtschema --upgrade > > Please check and re-submit after running the above command yourself. Note > that DT_SCHEMA_FILES can be set to your schema file to speed up checking > your schema. However, it must be unset to test all examples with your schema. > From baneric926 at gmail.com Fri Dec 22 12:27:17 2023 From: baneric926 at gmail.com (Ban Feng) Date: Fri, 22 Dec 2023 09:27:17 +0800 Subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <9035aff7-49e6-49cf-a8f8-619d3b53c4a5@linaro.org> References: <20231219080021.2048889-1-kcfeng0@nuvoton.com> <20231219080021.2048889-2-kcfeng0@nuvoton.com> <170297774900.1297817.5593278746406765111.robh@kernel.org> <9035aff7-49e6-49cf-a8f8-619d3b53c4a5@linaro.org> Message-ID: Hi Krzysztof, On Thu, Dec 21, 2023 at 4:20?PM Krzysztof Kozlowski wrote: > > On 21/12/2023 01:44, Ban Feng wrote: > > Hi Rob, > > > > On Tue, Dec 19, 2023 at 5:22?PM Rob Herring wrote: > >> > >> > >> On Tue, 19 Dec 2023 16:00:20 +0800, baneric926 at gmail.com wrote: > >>> From: Ban Feng > >>> > >>> Adding bindings for the Nuvoton NCT7363Y Fan Controller > >>> > >>> Signed-off-by: Ban Feng > >>> --- > >>> .../bindings/hwmon/nuvoton,nct7363.yaml | 62 +++++++++++++++++++ > >>> MAINTAINERS | 6 ++ > >>> 2 files changed, 68 insertions(+) > >>> create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml > >>> > >> > >> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' > >> on your patch (DT_CHECKER_FLAGS is new in v5.13): > > > > Our design is based on [1], and adds fan-common.yaml to > > Nothing in the patch or cover letter described the dependency. > ok, in v3, I'll attach a relevant patch and describe it in the cover letter. Thanks, Ban From baneric926 at gmail.com Fri Dec 22 12:33:49 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Fri, 22 Dec 2023 09:33:49 +0800 Subject: [PATCH v3 0/3] hwmon: Driver for Nuvoton NCT7363Y Message-ID: <20231222013352.3873689-1-kcfeng0@nuvoton.com> From: Ban Feng NCT7363Y is an I2C based hardware monitoring chip from Nuvoton. Changes since version 2: - Cherry-pick the fan-common.yaml in [1] - Fix nct736x typo and add unevaluatedProperties [1]: https://patchwork.kernel.org/project/linux-hwmon/patch/ 20231107105025.1480561-2-billy_tsai at aspeedtech.com/ Changes since version 1: - Modify NCT736X(nct736x) to NCT7363Y(nct7363) - Convert to devm_hwmon_device_register_with_info API - All ID tables are next to each other and should be consistent between i2c_device_id and of_device_id - Ref. fan-common.yaml and modify properties (nuvoton,pwm-mask/ nuvoton,fanin-mask) to (pwms/tach-ch) - Convert to devm_regmap_init_i2c API - Remove unused function (watchdog timer) - Fix uninitialized symbol which is reported by kernel test robot Ban Feng (2): dt-bindings: hwmon: Add NCT7363Y documentation hwmon: Driver for Nuvoton NCT7363Y Naresh Solanki (1): dt-bindings: hwmon: fan: Add fan binding to schema .../devicetree/bindings/hwmon/fan-common.yaml | 76 +++ .../bindings/hwmon/nuvoton,nct7363.yaml | 63 +++ Documentation/hwmon/index.rst | 1 + Documentation/hwmon/nct7363.rst | 33 ++ MAINTAINERS | 8 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/nct7363.c | 515 ++++++++++++++++++ 8 files changed, 708 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml create mode 100644 Documentation/hwmon/nct7363.rst create mode 100644 drivers/hwmon/nct7363.c -- 2.34.1 From baneric926 at gmail.com Fri Dec 22 12:33:50 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Fri, 22 Dec 2023 09:33:50 +0800 Subject: [PATCH v3 1/3] dt-bindings: hwmon: fan: Add fan binding to schema In-Reply-To: <20231222013352.3873689-1-kcfeng0@nuvoton.com> References: <20231222013352.3873689-1-kcfeng0@nuvoton.com> Message-ID: <20231222013352.3873689-2-kcfeng0@nuvoton.com> From: Naresh Solanki Add common fan properties bindings to a schema. Bindings for fan controllers can reference the common schema for the fan child nodes: patternProperties: "^fan@[0-2]": type: object $ref: fan-common.yaml# unevaluatedProperties: false Signed-off-by: Naresh Solanki Signed-off-by: Billy Tsai Signed-off-by: Ban Feng --- .../devicetree/bindings/hwmon/fan-common.yaml | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml diff --git a/Documentation/devicetree/bindings/hwmon/fan-common.yaml b/Documentation/devicetree/bindings/hwmon/fan-common.yaml new file mode 100644 index 000000000000..ba7d6531f01d --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/fan-common.yaml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/fan-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common Fan Properties + +maintainers: + - Naresh Solanki + - Billy Tsai + +properties: + max-rpm: + description: + Max RPM supported by fan. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 100000 + + min-rpm: + description: + Min RPM supported by fan. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 1000 + + pulses-per-revolution: + description: + The number of pulse from fan sensor per revolution. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 4 + + tach-div: + description: + Divisor for the tach sampling clock, which determines the sensitivity of the tach pin. + $ref: /schemas/types.yaml#/definitions/uint32 + + target-rpm: + description: + The default desired fan speed in RPM. + $ref: /schemas/types.yaml#/definitions/uint32 + + fan-driving-mode: + description: + Select the driving mode of the fan.(DC, PWM and so on) + $ref: /schemas/types.yaml#/definitions/string + + pwms: + description: + PWM provider. + maxItems: 1 + + "#cooling-cells": + const: 2 + + cooling-levels: + description: + The control value which correspond to thermal cooling states. + $ref: /schemas/types.yaml#/definitions/uint32-array + + tach-ch: + description: + The tach channel used for the fan. + $ref: /schemas/types.yaml#/definitions/uint8-array + + label: + description: + Optional fan label + + fan-supply: + description: + Power supply for fan. + + reg: + maxItems: 1 + +additionalProperties: true -- 2.34.1 From baneric926 at gmail.com Fri Dec 22 12:33:51 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Fri, 22 Dec 2023 09:33:51 +0800 Subject: [PATCH v3 2/3] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <20231222013352.3873689-1-kcfeng0@nuvoton.com> References: <20231222013352.3873689-1-kcfeng0@nuvoton.com> Message-ID: <20231222013352.3873689-3-kcfeng0@nuvoton.com> From: Ban Feng Adding bindings for the Nuvoton NCT7363Y Fan Controller Signed-off-by: Ban Feng --- .../bindings/hwmon/nuvoton,nct7363.yaml | 63 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml diff --git a/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml new file mode 100644 index 000000000000..1a9d9a5d614e --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/nuvoton,nct7363.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Nuvoton NCT7363Y Hardware Monitoring IC + +maintainers: + - Ban Feng + +description: | + The NCT7363Y is a Fan controller which provides up to 16 independent + FAN input monitors, and up to 16 independent PWM output with SMBus interface. + +properties: + compatible: + enum: + - nuvoton,nct7363 + + reg: + maxItems: 1 + + "#pwm-cells": + const: 2 + +patternProperties: + "^fan-[0-9]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + required: + - pwms + - tach-ch + +required: + - compatible + - reg + - "#pwm-cells" + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + hwmon: hwmon at 22 { + compatible = "nuvoton,nct7363"; + reg = <0x22>; + #pwm-cells = <2>; + + fan-0 { + pwms = <&hwmon 0 50000>; + tach-ch = /bits/ 8 <0x00>; + }; + fan-1 { + pwms = <&hwmon 1 50000>; + tach-ch = /bits/ 8 <0x01>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 7cef2d2ef8d7..53cfcc629aa1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14837,6 +14837,12 @@ S: Maintained F: Documentation/devicetree/bindings/hwmon/nuvoton,nct6775.yaml F: drivers/hwmon/nct6775-i2c.c +NCT736X HARDWARE MONITOR DRIVER +M: Ban Feng +L: linux-hwmon at vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml + NETDEVSIM M: Jakub Kicinski S: Maintained -- 2.34.1 From baneric926 at gmail.com Fri Dec 22 12:33:52 2023 From: baneric926 at gmail.com (baneric926 at gmail.com) Date: Fri, 22 Dec 2023 09:33:52 +0800 Subject: [PATCH v3 3/3] hwmon: Driver for Nuvoton NCT7363Y In-Reply-To: <20231222013352.3873689-1-kcfeng0@nuvoton.com> References: <20231222013352.3873689-1-kcfeng0@nuvoton.com> Message-ID: <20231222013352.3873689-4-kcfeng0@nuvoton.com> From: Ban Feng NCT7363Y is an I2C based hardware monitoring chip from Nuvoton. Signed-off-by: Ban Feng --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/nct7363.rst | 33 ++ MAINTAINERS | 2 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/nct7363.c | 515 ++++++++++++++++++++++++++++++++ 6 files changed, 563 insertions(+) create mode 100644 Documentation/hwmon/nct7363.rst create mode 100644 drivers/hwmon/nct7363.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 72f4e6065bae..178d3cae95de 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -161,6 +161,7 @@ Hardware Monitoring Kernel Drivers mp5023 nct6683 nct6775 + nct7363 nct7802 nct7904 npcm750-pwm-fan diff --git a/Documentation/hwmon/nct7363.rst b/Documentation/hwmon/nct7363.rst new file mode 100644 index 000000000000..89699c95aa4b --- /dev/null +++ b/Documentation/hwmon/nct7363.rst @@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver nct7363 +===================== + +Supported chip: + + * Nuvoton NCT7363Y + + Prefix: nct7363 + + Addresses: I2C 0x20, 0x21, 0x22, 0x23 + +Author: Ban Feng + + +Description +----------- + +The NCT7363Y is a Fan controller which provides up to 16 independent +FAN input monitors, and up to 16 independent PWM output with SMBus interface. + + +Sysfs entries +------------- + +Currently, the driver supports the following features: + +======================= ======================================================= +fanX_input provide current fan rotation value in RPM + +pwmX get or set PWM fan control value. +======================= ======================================================= diff --git a/MAINTAINERS b/MAINTAINERS index 53cfcc629aa1..e39c4fc01a3b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14842,6 +14842,8 @@ M: Ban Feng L: linux-hwmon at vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml +F: Documentation/hwmon/nct7363.rst +F: drivers/hwmon/nct7363.c NETDEVSIM M: Jakub Kicinski diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index cf27523eed5a..a0229851fc64 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1605,6 +1605,17 @@ config SENSORS_NCT6775_I2C This driver can also be built as a module. If so, the module will be called nct6775-i2c. +config SENSORS_NCT7363 + tristate "Nuvoton NCT7363Y" + depends on I2C + select REGMAP_I2C + help + If you say yes here you get support for the Nuvoton NCT7363Y, + hardware monitoring chip. + + This driver can also be built as a module. If so, the module + will be called nct7363. + config SENSORS_NCT7802 tristate "Nuvoton NCT7802Y" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index e84bd9685b5c..dd794aa06209 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -166,6 +166,7 @@ obj-$(CONFIG_SENSORS_NCT6775_CORE) += nct6775-core.o nct6775-objs := nct6775-platform.o obj-$(CONFIG_SENSORS_NCT6775) += nct6775.o obj-$(CONFIG_SENSORS_NCT6775_I2C) += nct6775-i2c.o +obj-$(CONFIG_SENSORS_NCT7363) += nct7363.o obj-$(CONFIG_SENSORS_NCT7802) += nct7802.o obj-$(CONFIG_SENSORS_NCT7904) += nct7904.o obj-$(CONFIG_SENSORS_NPCM7XX) += npcm750-pwm-fan.o diff --git a/drivers/hwmon/nct7363.c b/drivers/hwmon/nct7363.c new file mode 100644 index 000000000000..1bf6e83afd7f --- /dev/null +++ b/drivers/hwmon/nct7363.c @@ -0,0 +1,515 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023 Nuvoton Technology corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NCT7363_REG_GPIO_0_3 0x20 +#define NCT7363_REG_GPIO_4_7 0x21 +#define NCT7363_REG_GPIO_10_13 0x22 +#define NCT7363_REG_GPIO_14_17 0x23 +#define NCT7363_REG_PWMEN_0_7 0x38 +#define NCT7363_REG_PWMEN_8_15 0x39 +#define NCT7363_REG_FANINEN_0_7 0x41 +#define NCT7363_REG_FANINEN_8_15 0x42 +#define NCT7363_REG_FANINx_HVAL(x) (0x48 + ((x) * 2)) +#define NCT7363_REG_FANINx_LVAL(x) (0x49 + ((x) * 2)) +#define NCT7363_REG_FSCPxDUTY(x) (0x90 + ((x) * 2)) +#define NCT7363_REG_VENDOR_ID 0xFD +#define NCT7363_REG_CHIP_ID 0xFE +#define NCT7363_REG_DEVICE_ID 0xFF + +#define NUVOTON_ID 0x49 +#define CHIP_ID 0x19 +#define DEVICE_ID 0x88 + +#define PWM_SEL(x) (BIT(0) << ((x % 4) * 2)) +#define FANIN_SEL(x) (BIT(1) << ((x % 4) * 2)) +#define BIT_CHECK(x) (BIT(0) << x) + +#define NCT7363_FANINx_LVAL_MASK GENMASK(4, 0) +#define NCT7363_FANIN_MASK GENMASK(12, 0) + +#define NCT7363_PWM_COUNT 16 +#define NCT7363_FANIN_COUNT 16 + +#define REFRESH_INTERVAL (2 * HZ) + +static inline unsigned long FAN_FROM_REG(u16 val) +{ + if ((val >= NCT7363_FANIN_MASK) || (val == 0)) + return 0; + + return (1350000UL / val); +} + +static const unsigned short normal_i2c[] = { + 0x20, 0x21, 0x22, 0x23, I2C_CLIENT_END +}; + +enum chips { nct7363 }; + +static const struct i2c_device_id nct7363_id[] = { + { "nct7363", nct7363 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, nct7363_id); + +static const struct of_device_id nct7363_of_match[] = { + { .compatible = "nuvoton,nct7363", .data = (void *)nct7363 }, + { }, +}; +MODULE_DEVICE_TABLE(of, nct7363_of_match); + +struct nct7363_data { + struct regmap *regmap; + struct mutex update_lock; + bool valid; + unsigned long last_updated; /* In jiffies */ + + u16 fanin_mask; + u16 fan[NCT7363_FANIN_COUNT]; + u16 pwm_mask; + u8 pwm[NCT7363_PWM_COUNT]; +}; + +static struct nct7363_data *nct7363_update_device(struct device *dev) +{ + struct nct7363_data *data = dev_get_drvdata(dev); + unsigned int hi, lo, regval; + int i, ret = 0; + + mutex_lock(&data->update_lock); + + if (!(time_after(jiffies, data->last_updated + REFRESH_INTERVAL) + || !data->valid)) + goto no_sensor_update; + + for (i = 0; i < ARRAY_SIZE(data->fan); i++) { + if (!(data->fanin_mask & BIT_CHECK(i))) + continue; + + /* + * High-byte register should be read first to latch + * synchronous low-byte value + */ + ret = regmap_read(data->regmap, + NCT7363_REG_FANINx_HVAL(i), &hi); + if (ret) + goto error; + + ret = regmap_read(data->regmap, + NCT7363_REG_FANINx_LVAL(i), &lo); + if (ret) + goto error; + + data->fan[i] = (hi << 5) | (lo & NCT7363_FANINx_LVAL_MASK); + } + + for (i = 0; i < ARRAY_SIZE(data->pwm); i++) { + if (!(data->pwm_mask & BIT_CHECK(i))) + continue; + + ret = regmap_read(data->regmap, + NCT7363_REG_FSCPxDUTY(i), ®val); + if (ret) + goto error; + + data->pwm[i] = regval; + } + + data->last_updated = jiffies; + data->valid = true; + +error: + if (ret) + data = ERR_PTR(ret); + +no_sensor_update: + mutex_unlock(&data->update_lock); + + return data; +} + +static int nct7363_read_fan(struct device *dev, u32 attr, int channel, + long *val) +{ + struct nct7363_data *data = nct7363_update_device(dev); + u16 cnt, rpm; + + if (IS_ERR(data)) + return PTR_ERR(data); + + switch (attr) { + case hwmon_fan_input: + cnt = data->fan[channel] & NCT7363_FANIN_MASK; + rpm = FAN_FROM_REG(cnt); + *val = (long)rpm; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_fan_is_visible(const void *_data, u32 attr, int channel) +{ + const struct nct7363_data *data = _data; + + switch (attr) { + case hwmon_fan_input: + if (data->fanin_mask & BIT_CHECK(channel)) + return 0444; + break; + default: + break; + } + + return 0; +} + +static int nct7363_read_pwm(struct device *dev, u32 attr, int channel, + long *val) +{ + struct nct7363_data *data = nct7363_update_device(dev); + u16 ret; + + if (IS_ERR(data)) + return PTR_ERR(data); + + switch (attr) { + case hwmon_pwm_input: + ret = data->pwm[channel]; + *val = (long)ret; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int nct7363_write_pwm(struct device *dev, u32 attr, int channel, + long val) +{ + struct nct7363_data *data = nct7363_update_device(dev); + int ret; + + if (IS_ERR(data)) + return PTR_ERR(data); + + switch (attr) { + case hwmon_pwm_input: + if (val < 0 || val > 255) + return -EINVAL; + mutex_lock(&data->update_lock); + ret = regmap_write(data->regmap, + NCT7363_REG_FSCPxDUTY(channel), val); + if (ret == 0) + data->pwm[channel] = val; + mutex_unlock(&data->update_lock); + return ret; + + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_pwm_is_visible(const void *_data, u32 attr, int channel) +{ + const struct nct7363_data *data = _data; + + switch (attr) { + case hwmon_pwm_input: + if (data->pwm_mask & BIT_CHECK(channel)) + return 0644; + break; + default: + break; + } + + return 0; +} + +static int nct7363_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + switch (type) { + case hwmon_fan: + return nct7363_read_fan(dev, attr, channel, val); + case hwmon_pwm: + return nct7363_read_pwm(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static int nct7363_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + switch (type) { + case hwmon_pwm: + return nct7363_write_pwm(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_is_visible(const void *data, + enum hwmon_sensor_types type, + u32 attr, int channel) +{ + switch (type) { + case hwmon_fan: + return nct7363_fan_is_visible(data, attr, channel); + case hwmon_pwm: + return nct7363_pwm_is_visible(data, attr, channel); + default: + return 0; + } +} + +static const struct hwmon_channel_info *nct7363_info[] = { + HWMON_CHANNEL_INFO(fan, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT), + NULL +}; + +static const struct hwmon_ops nct7363_hwmon_ops = { + .is_visible = nct7363_is_visible, + .read = nct7363_read, + .write = nct7363_write, +}; + +static const struct hwmon_chip_info nct7363_chip_info = { + .ops = &nct7363_hwmon_ops, + .info = nct7363_info, +}; + +/* Return 0 if detection is successful, -ENODEV otherwise */ +static int nct7363_detect(struct i2c_client *client, + struct i2c_board_info *info) +{ + struct i2c_adapter *adapter = client->adapter; + int vendor, chip, device; + + if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + return -ENODEV; + + vendor = i2c_smbus_read_byte_data(client, NCT7363_REG_VENDOR_ID); + if (vendor != NUVOTON_ID) + return -ENODEV; + + chip = i2c_smbus_read_byte_data(client, NCT7363_REG_CHIP_ID); + if (chip != CHIP_ID) + return -ENODEV; + + device = i2c_smbus_read_byte_data(client, NCT7363_REG_DEVICE_ID); + if (device != DEVICE_ID) + return -ENODEV; + + strscpy(info->type, "nct7363", I2C_NAME_SIZE); + + return 0; +} + +static int nct7363_init_chip(struct nct7363_data *data) +{ + u8 i, gpio0_3 = 0, gpio4_7 = 0, gpio10_13 = 0, gpio14_17 = 0; + int ret; + + for (i = 0; i < NCT7363_PWM_COUNT; i++) { + if (i < 4) { + if (data->pwm_mask & BIT_CHECK(i)) + gpio0_3 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio10_13 |= FANIN_SEL(i); + } else if (i < 8) { + if (data->pwm_mask & BIT_CHECK(i)) + gpio4_7 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio14_17 |= FANIN_SEL(i); + } else if (i < 12) { + if (data->pwm_mask & BIT_CHECK(i)) + gpio10_13 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio0_3 |= FANIN_SEL(i); + } else { + if (data->pwm_mask & BIT_CHECK(i)) + gpio14_17 |= PWM_SEL(i); + if (data->fanin_mask & BIT_CHECK(i)) + gpio4_7 |= FANIN_SEL(i); + } + } + + /* Pin Function Configuration */ + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_0_3, gpio0_3); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_4_7, gpio4_7); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_10_13, gpio10_13); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_14_17, gpio14_17); + if (ret < 0) + return ret; + + /* PWM and FANIN Monitoring Enable */ + ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_0_7, + data->pwm_mask & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_8_15, + (data->pwm_mask >> 8) & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_0_7, + data->fanin_mask & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_8_15, + (data->fanin_mask >> 8) & 0xff); + if (ret < 0) + return ret; + + return 0; +} + +static int nct7363_present_pwm_fanin(struct device *dev, + struct device_node *child, + struct nct7363_data *data) +{ + struct of_phandle_args args; + int ret, fanin_cnt; + u8 *fanin_ch; + u8 ch, index; + + ret = of_parse_phandle_with_args(child, "pwms", "#pwm-cells", + 0, &args); + if (ret) + return ret; + + data->pwm_mask |= BIT(args.args[0]); + + fanin_cnt = of_property_count_u8_elems(child, "tach-ch"); + if (fanin_cnt < 1) + return -EINVAL; + + fanin_ch = devm_kcalloc(dev, fanin_cnt, sizeof(*fanin_ch), GFP_KERNEL); + if (!fanin_ch) + return -ENOMEM; + + ret = of_property_read_u8_array(child, "tach-ch", fanin_ch, fanin_cnt); + if (ret) + return ret; + + for (ch = 0; ch < fanin_cnt; ch++) { + index = fanin_ch[ch]; + data->fanin_mask |= BIT(index); + } + + return 0; +} + +static const struct regmap_config nct7363_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int nct7363_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct device_node *child; + struct nct7363_data *data; + struct device *hwmon_dev; + int ret; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->regmap = devm_regmap_init_i2c(client, &nct7363_regmap_config); + if (IS_ERR(data->regmap)) + return PTR_ERR(data->regmap); + + mutex_init(&data->update_lock); + + for_each_child_of_node(dev->of_node, child) { + ret = nct7363_present_pwm_fanin(dev, child, data); + if (ret) { + of_node_put(child); + return ret; + } + } + + /* Initialize the chip */ + ret = nct7363_init_chip(data); + if (ret) + return ret; + + hwmon_dev = + devm_hwmon_device_register_with_info(dev, client->name, data, + &nct7363_chip_info, NULL); + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static struct i2c_driver nct7363_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "nct7363", + .of_match_table = nct7363_of_match, + }, + .probe = nct7363_probe, + .id_table = nct7363_id, + .detect = nct7363_detect, + .address_list = normal_i2c, +}; + +module_i2c_driver(nct7363_driver); + +MODULE_AUTHOR("CW Ho "); +MODULE_AUTHOR("Ban Feng "); +MODULE_DESCRIPTION("NCT7363 Hardware Monitoring Driver"); +MODULE_LICENSE("GPL"); -- 2.34.1 From yujie.liu at intel.com Tue Dec 26 12:37:52 2023 From: yujie.liu at intel.com (kernel test robot) Date: Tue, 26 Dec 2023 09:37:52 +0800 Subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation In-Reply-To: <20231219080021.2048889-2-kcfeng0@nuvoton.com> Message-ID: <202312200129.7EYVeOyc-lkp@intel.com> Hi, kernel test robot noticed the following build warnings: [auto build test WARNING on linus/master] [also build test WARNING on v6.7-rc6 next-20231219] [cannot apply to groeck-staging/hwmon-next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/baneric926-gmail-com/dt-bindings-hwmon-Add-NCT7363Y-documentation/20231219-160534 base: linus/master patch link: https://lore.kernel.org/r/20231219080021.2048889-2-kcfeng0%40nuvoton.com patch subject: [PATCH v2 1/2] dt-bindings: hwmon: Add NCT7363Y documentation compiler: loongarch64-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231220/202312200129.7EYVeOyc-lkp at intel.com/reproduce) dtcheck warnings: (new ones prefixed by >>) >> Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml: Error in referenced schema matching $id: http://devicetree.org/schemas/hwmon/fan-common.yaml -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki From gutstuf at gmail.com Tue Dec 26 19:27:08 2023 From: gutstuf at gmail.com (=?UTF-8?B?0JPRg9GB0YLQvtCyINCS0LvQsNC00LjQvNC40YA=?=) Date: Tue, 26 Dec 2023 11:27:08 +0300 Subject: Submission of Individual CLA Message-ID: Good day! I send the signed `Individual CLA`. Please, approve and confirm. The PDF in the attachment. With regards, Gustov Vladimir -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenBMC.ICLA_signed.pdf Type: application/pdf Size: 78380 bytes Desc: not available URL: