| .. | .. |
|---|
| 1 | | -// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 2 | 2 | /* |
|---|
| 3 | | - * Copyright(c) 2017 Icenowy Zheng <icenowy@aosc.io> |
|---|
| 3 | + * Copyright(c) 2016, Analogix Semiconductor. |
|---|
| 4 | 4 | * |
|---|
| 5 | | - * Based on analogix-anx78xx.c, which is: |
|---|
| 6 | | - * Copyright(c) 2016, Analogix Semiconductor. All rights reserved. |
|---|
| 5 | + * Based on anx7808 driver obtained from chromeos with copyright: |
|---|
| 6 | + * Copyright(c) 2013, Google Inc. |
|---|
| 7 | 7 | */ |
|---|
| 8 | | - |
|---|
| 9 | | -#include <linux/module.h> |
|---|
| 10 | 8 | #include <linux/regmap.h> |
|---|
| 11 | 9 | |
|---|
| 12 | 10 | #include <drm/drm.h> |
|---|
| 13 | | -#include <drm/drmP.h> |
|---|
| 14 | 11 | #include <drm/drm_dp_helper.h> |
|---|
| 12 | +#include <drm/drm_print.h> |
|---|
| 15 | 13 | |
|---|
| 16 | 14 | #include "analogix-i2c-dptx.h" |
|---|
| 17 | 15 | |
|---|
| 18 | 16 | #define AUX_WAIT_TIMEOUT_MS 15 |
|---|
| 19 | 17 | #define AUX_CH_BUFFER_SIZE 16 |
|---|
| 20 | 18 | |
|---|
| 21 | | -static int anx_clear_bits(struct regmap *map, u8 reg, u8 mask) |
|---|
| 19 | +static int anx_i2c_dp_clear_bits(struct regmap *map, u8 reg, u8 mask) |
|---|
| 22 | 20 | { |
|---|
| 23 | 21 | return regmap_update_bits(map, reg, mask, 0); |
|---|
| 24 | 22 | } |
|---|
| 25 | 23 | |
|---|
| 26 | | -static bool anx_aux_op_finished(struct regmap *map_dptx) |
|---|
| 24 | +static bool anx_dp_aux_op_finished(struct regmap *map_dptx) |
|---|
| 27 | 25 | { |
|---|
| 28 | 26 | unsigned int value; |
|---|
| 29 | 27 | int err; |
|---|
| .. | .. |
|---|
| 35 | 33 | return (value & SP_AUX_EN) == 0; |
|---|
| 36 | 34 | } |
|---|
| 37 | 35 | |
|---|
| 38 | | -static int anx_aux_wait(struct regmap *map_dptx) |
|---|
| 36 | +static int anx_dp_aux_wait(struct regmap *map_dptx) |
|---|
| 39 | 37 | { |
|---|
| 40 | 38 | unsigned long timeout; |
|---|
| 41 | 39 | unsigned int status; |
|---|
| .. | .. |
|---|
| 43 | 41 | |
|---|
| 44 | 42 | timeout = jiffies + msecs_to_jiffies(AUX_WAIT_TIMEOUT_MS) + 1; |
|---|
| 45 | 43 | |
|---|
| 46 | | - while (!anx_aux_op_finished(map_dptx)) { |
|---|
| 44 | + while (!anx_dp_aux_op_finished(map_dptx)) { |
|---|
| 47 | 45 | if (time_after(jiffies, timeout)) { |
|---|
| 48 | | - if (!anx_aux_op_finished(map_dptx)) { |
|---|
| 46 | + if (!anx_dp_aux_op_finished(map_dptx)) { |
|---|
| 49 | 47 | DRM_ERROR("Timed out waiting AUX to finish\n"); |
|---|
| 50 | 48 | return -ETIMEDOUT; |
|---|
| 51 | 49 | } |
|---|
| .. | .. |
|---|
| 72 | 70 | return 0; |
|---|
| 73 | 71 | } |
|---|
| 74 | 72 | |
|---|
| 75 | | -static int anx_aux_address(struct regmap *map_dptx, unsigned int addr) |
|---|
| 73 | +static int anx_dp_aux_address(struct regmap *map_dptx, unsigned int addr) |
|---|
| 76 | 74 | { |
|---|
| 77 | 75 | int err; |
|---|
| 78 | 76 | |
|---|
| .. | .. |
|---|
| 100 | 98 | return 0; |
|---|
| 101 | 99 | } |
|---|
| 102 | 100 | |
|---|
| 103 | | -ssize_t anx_aux_transfer(struct regmap *map_dptx, struct drm_dp_aux_msg *msg) |
|---|
| 101 | +ssize_t anx_dp_aux_transfer(struct regmap *map_dptx, |
|---|
| 102 | + struct drm_dp_aux_msg *msg) |
|---|
| 104 | 103 | { |
|---|
| 105 | 104 | u8 ctrl1 = msg->request; |
|---|
| 106 | 105 | u8 ctrl2 = SP_AUX_EN; |
|---|
| .. | .. |
|---|
| 127 | 126 | } |
|---|
| 128 | 127 | |
|---|
| 129 | 128 | /* Write address and request */ |
|---|
| 130 | | - err = anx_aux_address(map_dptx, msg->address); |
|---|
| 129 | + err = anx_dp_aux_address(map_dptx, msg->address); |
|---|
| 131 | 130 | if (err) |
|---|
| 132 | 131 | return err; |
|---|
| 133 | 132 | |
|---|
| .. | .. |
|---|
| 141 | 140 | if (err) |
|---|
| 142 | 141 | return err; |
|---|
| 143 | 142 | |
|---|
| 144 | | - err = anx_aux_wait(map_dptx); |
|---|
| 143 | + err = anx_dp_aux_wait(map_dptx); |
|---|
| 145 | 144 | if (err) |
|---|
| 146 | 145 | return err; |
|---|
| 147 | 146 | |
|---|
| .. | .. |
|---|
| 156 | 155 | return err; |
|---|
| 157 | 156 | } |
|---|
| 158 | 157 | |
|---|
| 159 | | - err = anx_clear_bits(map_dptx, SP_DP_AUX_CH_CTRL2_REG, SP_ADDR_ONLY); |
|---|
| 158 | + err = anx_i2c_dp_clear_bits(map_dptx, SP_DP_AUX_CH_CTRL2_REG, |
|---|
| 159 | + SP_ADDR_ONLY); |
|---|
| 160 | 160 | if (err) |
|---|
| 161 | 161 | return err; |
|---|
| 162 | 162 | |
|---|
| 163 | 163 | return msg->size; |
|---|
| 164 | 164 | } |
|---|
| 165 | | -EXPORT_SYMBOL(anx_aux_transfer); |
|---|
| 166 | | - |
|---|
| 167 | | -MODULE_DESCRIPTION("Analogix DisplayPort Transmitter common code"); |
|---|
| 168 | | -MODULE_AUTHOR("Icenowy Zheng <icenowy@aosc.io>"); |
|---|
| 169 | | -MODULE_LICENSE("GPL v2"); |
|---|
| 165 | +EXPORT_SYMBOL_GPL(anx_dp_aux_transfer); |
|---|