coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
tsadc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <device/mmio.h>
4 #include <soc/clock.h>
5 #include <soc/grf.h>
6 #include <soc/pmu.h>
7 #include <soc/tsadc.h>
8 #include <stdint.h>
9 
15  u32 reserved0[(0x20 - 0x10) / 4];
28  u32 reserved1[(0x60 - 0x50) / 4];
33 };
34 check_member(rk3288_tsadc_regs, auto_period_ht, 0x6c);
35 
36 /* auto_con */
37 #define LAST_TSHUT (1 << 24)
38 #define TSHUT_POL_HIGH (1 << 8)
39 #define SRC3_EN (1 << 7)
40 #define SRC2_EN (1 << 6)
41 #define SRC1_EN (1 << 5)
42 #define SRC0_EN (1 << 4)
43 #define AUTO_EN (1 << 0)
44 
45 /* int_en */
46 #define TSHUT_CRU_EN_SRC3 (1 << 11)
47 #define TSHUT_CRU_EN_SRC2 (1 << 10)
48 #define TSHUT_CRU_EN_SRC1 (1 << 9)
49 #define TSHUT_CRU_EN_SRC0 (1 << 8)
50 #define TSHUT_GPIO_EN_SRC3 (1 << 7)
51 #define TSHUT_GPIO_EN_SRC2 (1 << 6)
52 #define TSHUT_GPIO_EN_SRC1 (1 << 5)
53 #define TSHUT_GPIO_EN_SRC0 (1 << 4)
54 
55 #define AUTO_PERIOD 10
56 #define AUTO_DEBOUNCE 4
57 #define AUTO_PERIOD_HT 10
58 #define AUTO_DEBOUNCE_HT 4
59 #define TSADC_CLOCK_HZ (8 * KHz)
60 
61 /* AD value, correspond to 120 degrees Celsius */
62 #define TSADC_SHUT_VALUE 3437
63 
65 
66 void tsadc_init(void)
67 {
69 
71 
75 
80 
83 
84  /* polarity set to high,channel1 for cpu,channel2 for gpu */
86  SRC1_EN | AUTO_EN);
87 
88  /*
89  tsadc iomux must be set after the tshut polarity setting,
90  since the tshut polarity default low active,
91  so if you enable tsadc iomux,it will output high
92  */
94 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
#define setbits32(addr, set)
Definition: mmio.h:21
#define IOMUX_TSADC_INT
Definition: pmu.h:59
static struct rk3288_pmu_regs *const rk3288_pmu
Definition: pmu.h:55
#define SRC2_EN
Definition: tsadc.c:40
#define AUTO_DEBOUNCE
Definition: tsadc.c:56
void tsadc_init(void)
Definition: tsadc.c:66
#define TSHUT_CRU_EN_SRC1
Definition: tsadc.c:48
#define AUTO_DEBOUNCE_HT
Definition: tsadc.c:58
#define TSHUT_GPIO_EN_SRC1
Definition: tsadc.c:52
check_member(rk3288_tsadc_regs, auto_period_ht, 0x6c)
#define TSHUT_GPIO_EN_SRC2
Definition: tsadc.c:51
#define TSHUT_CRU_EN_SRC2
Definition: tsadc.c:47
#define TSADC_CLOCK_HZ
Definition: tsadc.c:59
#define TSADC_SHUT_VALUE
Definition: tsadc.c:62
#define AUTO_PERIOD_HT
Definition: tsadc.c:57
#define SRC1_EN
Definition: tsadc.c:41
#define AUTO_EN
Definition: tsadc.c:43
struct rk3288_tsadc_regs * rk3288_tsadc
Definition: tsadc.c:64
#define AUTO_PERIOD
Definition: tsadc.c:55
#define TSHUT_POL_HIGH
Definition: tsadc.c:38
#define LAST_TSHUT
Definition: tsadc.c:37
void rkclk_configure_tsadc(unsigned int hz)
Definition: clock.c:482
#define TSADC_BASE
Definition: addressmap.h:24
uint32_t u32
Definition: stdint.h:51
u32 iomux_tsadc_int
Definition: pmu.h:41
u32 comp3_shut
Definition: tsadc.c:27
u32 auto_period_ht
Definition: tsadc.c:32
u32 reserved0[(0x20 - 0x10)/4]
Definition: tsadc.c:15
u32 hight_tshut_debounce
Definition: tsadc.c:30
u32 hight_int_debounce
Definition: tsadc.c:29
u32 comp0_shut
Definition: tsadc.c:24
u32 comp2_shut
Definition: tsadc.c:26
u32 comp1_shut
Definition: tsadc.c:25
u32 auto_period
Definition: tsadc.c:31
u32 reserved1[(0x60 - 0x50)/4]
Definition: tsadc.c:28