diff mbox series

[10/33] fsi: aspeed: Add AST2700 support

Message ID 20240215220759.976998-11-eajames@linux.ibm.com
State Superseded
Headers show
Series [01/33] dt-bindings: clock: ast2600: Add FSI clock | expand

Commit Message

Eddie James Feb. 15, 2024, 10:07 p.m. UTC
AST2700 requires a few bits set differently in the OPB retry
counter register, so add some match data and set the register
accordingly.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/fsi/fsi-master-aspeed.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

Comments

Krzysztof Kozlowski Feb. 16, 2024, 8:09 a.m. UTC | #1
On 15/02/2024 23:07, Eddie James wrote:
> AST2700 requires a few bits set differently in the OPB retry
> counter register, so add some match data and set the register
> accordingly.
> 
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
>  drivers/fsi/fsi-master-aspeed.c | 28 +++++++++++++++++++++++++---


> +
>  static const struct of_device_id fsi_master_aspeed_match[] = {
> -	{ .compatible = "aspeed,ast2600-fsi-master" },
> +	{
> +		.compatible = "aspeed,ast2600-fsi-master",
> +		.data = &fsi_master_ast2600_data,
> +	},
> +	{
> +		.compatible = "aspeed,ast2700-fsi-master",

Undocumented. Really, you do not have checkpatch in IBM?

Please run scripts/checkpatch.pl and fix reported warnings. Some
warnings can be ignored, but the code here looks like it needs a fix.
Feel free to get in touch if the warning is not clear.


Best regards,
Krzysztof
Eddie James Feb. 16, 2024, 7:18 p.m. UTC | #2
On 2/16/24 02:09, Krzysztof Kozlowski wrote:
> On 15/02/2024 23:07, Eddie James wrote:
>> AST2700 requires a few bits set differently in the OPB retry
>> counter register, so add some match data and set the register
>> accordingly.
>>
>> Signed-off-by: Eddie James <eajames@linux.ibm.com>
>> ---
>>   drivers/fsi/fsi-master-aspeed.c | 28 +++++++++++++++++++++++++---
>
>> +
>>   static const struct of_device_id fsi_master_aspeed_match[] = {
>> -	{ .compatible = "aspeed,ast2600-fsi-master" },
>> +	{
>> +		.compatible = "aspeed,ast2600-fsi-master",
>> +		.data = &fsi_master_ast2600_data,
>> +	},
>> +	{
>> +		.compatible = "aspeed,ast2700-fsi-master",
> Undocumented. Really, you do not have checkpatch in IBM?
>
> Please run scripts/checkpatch.pl and fix reported warnings. Some
> warnings can be ignored, but the code here looks like it needs a fix.
> Feel free to get in touch if the warning is not clear.


I ran checkpatch. There are several FSI drivers with undocumented 
compatible strings, and the Aspeed master documentation isn't in yaml 
format, so that would require an update too. Therefore I ignored the 
warning - my mistake. I will document it in v2.


>
>
> Best regards,
> Krzysztof
>
diff mbox series

Patch

diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c
index f0a19cd451a0..d6e923b8f501 100644
--- a/drivers/fsi/fsi-master-aspeed.c
+++ b/drivers/fsi/fsi-master-aspeed.c
@@ -18,6 +18,10 @@ 
 
 #include "fsi-master.h"
 
+struct fsi_master_aspeed_data {
+	u32 opb_retry_counter;
+};
+
 struct fsi_master_aspeed {
 	struct fsi_master	master;
 	struct mutex		lock;	/* protect HW access */
@@ -60,6 +64,8 @@  static const u32 fsi_base = 0xa0000000;
 #define OPB1_READ_ORDER2	0x60
 
 #define OPB_RETRY_COUNTER	0x64
+#define OPB_RETRY_COUNTER_AST2600	0x00000010
+#define OPB_RETRY_COUNTER_AST2700	0x000c0010
 
 /* OPBn_STATUS */
 #define STATUS_HALFWORD_ACK	BIT(0)
@@ -536,6 +542,8 @@  static int tacoma_cabled_fsi_fixup(struct device *dev)
 
 static int fsi_master_aspeed_probe(struct platform_device *pdev)
 {
+	const struct fsi_master_aspeed_data *md = of_device_get_match_data(&pdev->dev);
+	u32 opb_retry_counter = md ? md->opb_retry_counter : OPB_RETRY_COUNTER_AST2600;
 	struct fsi_master_aspeed *aspeed;
 	int rc, links, reg;
 	__be32 raw;
@@ -579,8 +587,7 @@  static int fsi_master_aspeed_probe(struct platform_device *pdev)
 	writel(OPB1_XFER_ACK_EN | OPB0_XFER_ACK_EN,
 			aspeed->base + OPB_IRQ_MASK);
 
-	/* TODO: determine an appropriate value */
-	writel(0x10, aspeed->base + OPB_RETRY_COUNTER);
+	writel(opb_retry_counter, aspeed->base + OPB_RETRY_COUNTER);
 
 	writel(ctrl_base, aspeed->base + OPB_CTRL_BASE);
 	writel(fsi_base, aspeed->base + OPB_FSI_BASE);
@@ -656,8 +663,23 @@  static int fsi_master_aspeed_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct fsi_master_aspeed_data fsi_master_ast2600_data = {
+	.opb_retry_counter = OPB_RETRY_COUNTER_AST2600,
+};
+
+static const struct fsi_master_aspeed_data fsi_master_ast2700_data = {
+	.opb_retry_counter = OPB_RETRY_COUNTER_AST2700,
+};
+
 static const struct of_device_id fsi_master_aspeed_match[] = {
-	{ .compatible = "aspeed,ast2600-fsi-master" },
+	{
+		.compatible = "aspeed,ast2600-fsi-master",
+		.data = &fsi_master_ast2600_data,
+	},
+	{
+		.compatible = "aspeed,ast2700-fsi-master",
+		.data = &fsi_master_ast2700_data,
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, fsi_master_aspeed_match);