net: phy: qcom: move common qca808x LED define to shared header
authorChristian Marangi <ansuelsmth@gmail.com>
Tue, 6 Feb 2024 17:31:11 +0000 (18:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 10 Feb 2024 15:36:19 +0000 (15:36 +0000)
The LED implementation of qca808x and qca807x is the same but qca807x
supports also Fiber port and have different hw control bits for Fiber
port.

In preparation for qca807x introduction, move all the common define to
shared header.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/qcom/qca808x.c
drivers/net/phy/qcom/qcom.h

index 8377325..f1edff6 100644 (file)
 #define QCA808X_DBG_AN_TEST                    0xb
 #define QCA808X_HIBERNATION_EN                 BIT(15)
 
-#define QCA808X_MMD7_LED_GLOBAL                        0x8073
-#define QCA808X_LED_BLINK_1                    GENMASK(11, 6)
-#define QCA808X_LED_BLINK_2                    GENMASK(5, 0)
-/* Values are the same for both BLINK_1 and BLINK_2 */
-#define QCA808X_LED_BLINK_FREQ_MASK            GENMASK(5, 3)
-#define QCA808X_LED_BLINK_FREQ_2HZ             FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0)
-#define QCA808X_LED_BLINK_FREQ_4HZ             FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1)
-#define QCA808X_LED_BLINK_FREQ_8HZ             FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2)
-#define QCA808X_LED_BLINK_FREQ_16HZ            FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3)
-#define QCA808X_LED_BLINK_FREQ_32HZ            FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4)
-#define QCA808X_LED_BLINK_FREQ_64HZ            FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5)
-#define QCA808X_LED_BLINK_FREQ_128HZ           FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6)
-#define QCA808X_LED_BLINK_FREQ_256HZ           FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7)
-#define QCA808X_LED_BLINK_DUTY_MASK            GENMASK(2, 0)
-#define QCA808X_LED_BLINK_DUTY_50_50           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0)
-#define QCA808X_LED_BLINK_DUTY_75_25           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1)
-#define QCA808X_LED_BLINK_DUTY_25_75           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2)
-#define QCA808X_LED_BLINK_DUTY_33_67           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3)
-#define QCA808X_LED_BLINK_DUTY_67_33           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4)
-#define QCA808X_LED_BLINK_DUTY_17_83           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5)
-#define QCA808X_LED_BLINK_DUTY_83_17           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6)
-#define QCA808X_LED_BLINK_DUTY_8_92            FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7)
-
 #define QCA808X_MMD7_LED2_CTRL                 0x8074
 #define QCA808X_MMD7_LED2_FORCE_CTRL           0x8075
 #define QCA808X_MMD7_LED1_CTRL                 0x8076
 #define QCA808X_MMD7_LED0_CTRL                 0x8078
 #define QCA808X_MMD7_LED_CTRL(x)               (0x8078 - ((x) * 2))
 
-/* LED hw control pattern is the same for every LED */
-#define QCA808X_LED_PATTERN_MASK               GENMASK(15, 0)
-#define QCA808X_LED_SPEED2500_ON               BIT(15)
-#define QCA808X_LED_SPEED2500_BLINK            BIT(14)
-/* Follow blink trigger even if duplex or speed condition doesn't match */
-#define QCA808X_LED_BLINK_CHECK_BYPASS         BIT(13)
-#define QCA808X_LED_FULL_DUPLEX_ON             BIT(12)
-#define QCA808X_LED_HALF_DUPLEX_ON             BIT(11)
-#define QCA808X_LED_TX_BLINK                   BIT(10)
-#define QCA808X_LED_RX_BLINK                   BIT(9)
-#define QCA808X_LED_TX_ON_10MS                 BIT(8)
-#define QCA808X_LED_RX_ON_10MS                 BIT(7)
-#define QCA808X_LED_SPEED1000_ON               BIT(6)
-#define QCA808X_LED_SPEED100_ON                        BIT(5)
-#define QCA808X_LED_SPEED10_ON                 BIT(4)
-#define QCA808X_LED_COLLISION_BLINK            BIT(3)
-#define QCA808X_LED_SPEED1000_BLINK            BIT(2)
-#define QCA808X_LED_SPEED100_BLINK             BIT(1)
-#define QCA808X_LED_SPEED10_BLINK              BIT(0)
-
 #define QCA808X_MMD7_LED0_FORCE_CTRL           0x8079
 #define QCA808X_MMD7_LED_FORCE_CTRL(x)         (0x8079 - ((x) * 2))
 
-/* LED force ctrl is the same for every LED
- * No documentation exist for this, not even internal one
- * with NDA as QCOM gives only info about configuring
- * hw control pattern rules and doesn't indicate any way
- * to force the LED to specific mode.
- * These define comes from reverse and testing and maybe
- * lack of some info or some info are not entirely correct.
- * For the basic LED control and hw control these finding
- * are enough to support LED control in all the required APIs.
- *
- * On doing some comparison with implementation with qca807x,
- * it was found that it's 1:1 equal to it and confirms all the
- * reverse done. It was also found further specification with the
- * force mode and the blink modes.
- */
-#define QCA808X_LED_FORCE_EN                   BIT(15)
-#define QCA808X_LED_FORCE_MODE_MASK            GENMASK(14, 13)
-#define QCA808X_LED_FORCE_BLINK_1              FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3)
-#define QCA808X_LED_FORCE_BLINK_2              FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2)
-#define QCA808X_LED_FORCE_ON                   FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1)
-#define QCA808X_LED_FORCE_OFF                  FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0)
-
 #define QCA808X_MMD7_LED_POLARITY_CTRL         0x901a
 /* QSDK sets by default 0x46 to this reg that sets BIT 6 for
  * LED to active high. It's not clear what BIT 3 and BIT 4 does.
index dc259bb..9e24997 100644 (file)
 /* Added for reference of existence but should be handled by wait_for_completion already */
 #define QCA808X_CDT_STATUS_STAT_BUSY           (BIT(1) | BIT(3))
 
+#define QCA808X_MMD7_LED_GLOBAL                        0x8073
+#define QCA808X_LED_BLINK_1                    GENMASK(11, 6)
+#define QCA808X_LED_BLINK_2                    GENMASK(5, 0)
+/* Values are the same for both BLINK_1 and BLINK_2 */
+#define QCA808X_LED_BLINK_FREQ_MASK            GENMASK(5, 3)
+#define QCA808X_LED_BLINK_FREQ_2HZ             FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0)
+#define QCA808X_LED_BLINK_FREQ_4HZ             FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1)
+#define QCA808X_LED_BLINK_FREQ_8HZ             FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2)
+#define QCA808X_LED_BLINK_FREQ_16HZ            FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3)
+#define QCA808X_LED_BLINK_FREQ_32HZ            FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4)
+#define QCA808X_LED_BLINK_FREQ_64HZ            FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5)
+#define QCA808X_LED_BLINK_FREQ_128HZ           FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6)
+#define QCA808X_LED_BLINK_FREQ_256HZ           FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7)
+#define QCA808X_LED_BLINK_DUTY_MASK            GENMASK(2, 0)
+#define QCA808X_LED_BLINK_DUTY_50_50           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0)
+#define QCA808X_LED_BLINK_DUTY_75_25           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1)
+#define QCA808X_LED_BLINK_DUTY_25_75           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2)
+#define QCA808X_LED_BLINK_DUTY_33_67           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3)
+#define QCA808X_LED_BLINK_DUTY_67_33           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4)
+#define QCA808X_LED_BLINK_DUTY_17_83           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5)
+#define QCA808X_LED_BLINK_DUTY_83_17           FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6)
+#define QCA808X_LED_BLINK_DUTY_8_92            FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7)
+
+/* LED hw control pattern is the same for every LED */
+#define QCA808X_LED_PATTERN_MASK               GENMASK(15, 0)
+#define QCA808X_LED_SPEED2500_ON               BIT(15)
+#define QCA808X_LED_SPEED2500_BLINK            BIT(14)
+/* Follow blink trigger even if duplex or speed condition doesn't match */
+#define QCA808X_LED_BLINK_CHECK_BYPASS         BIT(13)
+#define QCA808X_LED_FULL_DUPLEX_ON             BIT(12)
+#define QCA808X_LED_HALF_DUPLEX_ON             BIT(11)
+#define QCA808X_LED_TX_BLINK                   BIT(10)
+#define QCA808X_LED_RX_BLINK                   BIT(9)
+#define QCA808X_LED_TX_ON_10MS                 BIT(8)
+#define QCA808X_LED_RX_ON_10MS                 BIT(7)
+#define QCA808X_LED_SPEED1000_ON               BIT(6)
+#define QCA808X_LED_SPEED100_ON                        BIT(5)
+#define QCA808X_LED_SPEED10_ON                 BIT(4)
+#define QCA808X_LED_COLLISION_BLINK            BIT(3)
+#define QCA808X_LED_SPEED1000_BLINK            BIT(2)
+#define QCA808X_LED_SPEED100_BLINK             BIT(1)
+#define QCA808X_LED_SPEED10_BLINK              BIT(0)
+
+/* LED force ctrl is the same for every LED
+ * No documentation exist for this, not even internal one
+ * with NDA as QCOM gives only info about configuring
+ * hw control pattern rules and doesn't indicate any way
+ * to force the LED to specific mode.
+ * These define comes from reverse and testing and maybe
+ * lack of some info or some info are not entirely correct.
+ * For the basic LED control and hw control these finding
+ * are enough to support LED control in all the required APIs.
+ *
+ * On doing some comparison with implementation with qca807x,
+ * it was found that it's 1:1 equal to it and confirms all the
+ * reverse done. It was also found further specification with the
+ * force mode and the blink modes.
+ */
+#define QCA808X_LED_FORCE_EN                   BIT(15)
+#define QCA808X_LED_FORCE_MODE_MASK            GENMASK(14, 13)
+#define QCA808X_LED_FORCE_BLINK_1              FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3)
+#define QCA808X_LED_FORCE_BLINK_2              FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2)
+#define QCA808X_LED_FORCE_ON                   FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1)
+#define QCA808X_LED_FORCE_OFF                  FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0)
+
 #define AT803X_LOC_MAC_ADDR_0_15_OFFSET                0x804C
 #define AT803X_LOC_MAC_ADDR_16_31_OFFSET       0x804B
 #define AT803X_LOC_MAC_ADDR_32_47_OFFSET       0x804A