15f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon/* 25f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * AMD CS5535/CS5536 definitions 35f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * Copyright (C) 2006 Advanced Micro Devices, Inc. 45f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * Copyright (C) 2009 Andres Salomon <dilinger@collabora.co.uk> 55f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * 65f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * This program is free software; you can redistribute it and/or 75f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * modify it under the terms of version 2 of the GNU General Public License 85f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon * as published by the Free Software Foundation. 95f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon */ 105f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 115f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#ifndef _CS5535_H 125f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define _CS5535_H 135f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 147bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake#include <asm/msr.h> 157bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake 165f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon/* MSRs */ 17f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_GLIU_P2D_RO0 0x10000029 18f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon 19f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_LX_GLD_MSR_CONFIG 0x48002001 20f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_LX_MSR_PADSEL 0x48002011 /* NOT 0x48000011; the data 21f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon * sheet has the wrong value */ 22f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_GLCP_SYS_RSTPLL 0x4C000014 23f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_GLCP_DOTPLL 0x4C000015 24f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon 255f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define MSR_LBAR_SMB 0x5140000B 265f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define MSR_LBAR_GPIO 0x5140000C 275f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define MSR_LBAR_MFGPT 0x5140000D 285f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define MSR_LBAR_ACPI 0x5140000E 295f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define MSR_LBAR_PMS 0x5140000F 305f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 312e8c12436f540d3c40137ebf10268803dc972f6aAndres Salomon#define MSR_DIVIL_SOFT_RESET 0x51400017 322e8c12436f540d3c40137ebf10268803dc972f6aAndres Salomon 3382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_PIC_YSEL_LOW 0x51400020 3482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_PIC_YSEL_HIGH 0x51400021 3582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_PIC_ZSEL_LOW 0x51400022 3682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_PIC_ZSEL_HIGH 0x51400023 3782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_PIC_IRQM_LPC 0x51400025 3882dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 3982dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_MFGPT_IRQ 0x51400028 4082dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_MFGPT_NR 0x51400029 4182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MSR_MFGPT_SETUP 0x5140002B 4282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 43cfee95977bea090ae5ec4fd442ebd381792d46c4Daniel Drake#define MSR_RTC_DOMA_OFFSET 0x51400055 44cfee95977bea090ae5ec4fd442ebd381792d46c4Daniel Drake#define MSR_RTC_MONA_OFFSET 0x51400056 45cfee95977bea090ae5ec4fd442ebd381792d46c4Daniel Drake#define MSR_RTC_CEN_OFFSET 0x51400057 46cfee95977bea090ae5ec4fd442ebd381792d46c4Daniel Drake 47f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_LX_SPARE_MSR 0x80000011 /* DC-specific */ 48f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon 49f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_GX_GLD_MSR_CONFIG 0xC0002001 50f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon#define MSR_GX_MSR_PADSEL 0xC0002011 51f3a57a60d3e107d17aebb9e52b61c503e5bc14f9Andres Salomon 527bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drakestatic inline int cs5535_pic_unreqz_select_high(unsigned int group, 537bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake unsigned int irq) 547bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake{ 557bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake uint32_t lo, hi; 567bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake 577bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake rdmsr(MSR_PIC_ZSEL_HIGH, lo, hi); 587bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake lo &= ~(0xF << (group * 4)); 597bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake lo |= (irq & 0xF) << (group * 4); 607bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake wrmsr(MSR_PIC_ZSEL_HIGH, lo, hi); 617bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake return 0; 627bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake} 637bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake 647feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake/* PIC registers */ 657feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake#define CS5536_PIC_INT_SEL1 0x4d0 667feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake#define CS5536_PIC_INT_SEL2 0x4d1 677feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake 685f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon/* resource sizes */ 695f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define LBAR_GPIO_SIZE 0xFF 705f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define LBAR_MFGPT_SIZE 0x40 715f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define LBAR_ACPI_SIZE 0x40 725f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define LBAR_PMS_SIZE 0x80 735f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 747a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake/* 757a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake * PMC registers (PMS block) 767a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake * It is only safe to access these registers as dword accesses. 777a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake * See CS5536 Specification Update erratas 17 & 18 787a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake */ 797a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM_SCLK 0x10 807a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM_IN_SLPCTL 0x20 817a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM_WKXD 0x34 827a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM_WKD 0x30 837a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM_SSC 0x54 847a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake 857a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake/* 867a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake * PM registers (ACPI block) 877a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake * It is only safe to access these registers as dword accesses. 887a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake * See CS5536 Specification Update erratas 17 & 18 897a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake */ 907a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM1_STS 0x00 917a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM1_EN 0x02 927a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM1_CNT 0x08 937a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake#define CS5536_PM_GPE0_STS 0x18 947bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake#define CS5536_PM_GPE0_EN 0x1c 957a0d4fcf6d4b80b30503fd2701eeef1883e11404Daniel Drake 967feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake/* CS5536_PM1_STS bits */ 977feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake#define CS5536_WAK_FLAG (1 << 15) 987feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake#define CS5536_PWRBTN_FLAG (1 << 8) 997feda8e9f35ebb0e9f90e03acb02280bc137f784Daniel Drake 10097c4cb71c18fe045a763ff6681a8ebbbbbec0b2bDaniel Drake/* CS5536_PM1_EN bits */ 10197c4cb71c18fe045a763ff6681a8ebbbbbec0b2bDaniel Drake#define CS5536_PM_PWRBTN (1 << 8) 102cfee95977bea090ae5ec4fd442ebd381792d46c4Daniel Drake#define CS5536_PM_RTC (1 << 10) 10397c4cb71c18fe045a763ff6681a8ebbbbbec0b2bDaniel Drake 1047bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake/* CS5536_PM_GPE0_STS bits */ 1057bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake#define CS5536_GPIOM7_PME_FLAG (1 << 31) 1067bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake#define CS5536_GPIOM6_PME_FLAG (1 << 30) 1077bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake 1087bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake/* CS5536_PM_GPE0_EN bits */ 1097bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake#define CS5536_GPIOM7_PME_EN (1 << 31) 1102cf2baea103f0a3d68b0f989d28df66f16dbc834Daniel Drake#define CS5536_GPIOM6_PME_EN (1 << 30) 1117bc74b3df73776fe06f3df9fafd2d2698e6ca28aDaniel Drake 112f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon/* VSA2 magic values */ 113f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define VSA_VRC_INDEX 0xAC1C 114f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define VSA_VRC_DATA 0xAC1E 115f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define VSA_VR_UNLOCK 0xFC53 /* unlock virtual register */ 116f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define VSA_VR_SIGNATURE 0x0003 117f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define VSA_VR_MEM_SIZE 0x0200 118f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define AMD_VSA_SIG 0x4132 /* signature is ascii 'VSA2' */ 119f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#define GSW_VSA_SIG 0x534d /* General Software signature */ 120f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 121f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon#include <linux/io.h> 122f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 123f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomonstatic inline int cs5535_has_vsa2(void) 124f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon{ 125f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon static int has_vsa2 = -1; 126f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 127f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon if (has_vsa2 == -1) { 128f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon uint16_t val; 129f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 130f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon /* 131f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon * The VSA has virtual registers that we can query for a 132f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon * signature. 133f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon */ 134f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon outw(VSA_VR_UNLOCK, VSA_VRC_INDEX); 135f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon outw(VSA_VR_SIGNATURE, VSA_VRC_INDEX); 136f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 137f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon val = inw(VSA_VRC_DATA); 138f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon has_vsa2 = (val == AMD_VSA_SIG || val == GSW_VSA_SIG); 139f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon } 140f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 141f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon return has_vsa2; 142f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon} 143f060f27007b393bac6e50ee6fc26d8505acf6fe4Andres Salomon 1445f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon/* GPIOs */ 1455f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_OUTPUT_VAL 0x00 1465f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_OUTPUT_ENABLE 0x04 1475f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_OUTPUT_OPEN_DRAIN 0x08 1485f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_OUTPUT_INVERT 0x0C 1495f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_OUTPUT_AUX1 0x10 1505f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_OUTPUT_AUX2 0x14 1515f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_PULL_UP 0x18 1525f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_PULL_DOWN 0x1C 1535f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_INPUT_ENABLE 0x20 1545f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_INPUT_INVERT 0x24 1555f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_INPUT_FILTER 0x28 1565f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_INPUT_EVENT_COUNT 0x2C 1575f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_READ_BACK 0x30 1585f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_INPUT_AUX1 0x34 1595f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_EVENTS_ENABLE 0x38 1605f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_LOCK_ENABLE 0x3C 1615f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_POSITIVE_EDGE_EN 0x40 1625f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_NEGATIVE_EDGE_EN 0x44 1635f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_POSITIVE_EDGE_STS 0x48 1645f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_NEGATIVE_EDGE_STS 0x4C 1655f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 1667637c9259f7b6dd841471ccf1120d484b7364f99Andres Salomon#define GPIO_FLTR7_AMOUNT 0xD8 1677637c9259f7b6dd841471ccf1120d484b7364f99Andres Salomon 1685f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_MAP_X 0xE0 1695f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_MAP_Y 0xE4 1705f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_MAP_Z 0xE8 1715f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#define GPIO_MAP_W 0xEC 1725f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 1737637c9259f7b6dd841471ccf1120d484b7364f99Andres Salomon#define GPIO_FE7_SEL 0xF7 1747637c9259f7b6dd841471ccf1120d484b7364f99Andres Salomon 1755f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomonvoid cs5535_gpio_set(unsigned offset, unsigned int reg); 1765f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomonvoid cs5535_gpio_clear(unsigned offset, unsigned int reg); 1775f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomonint cs5535_gpio_isset(unsigned offset, unsigned int reg); 1781b912c1bca5c162e611384fe7d39c916e081701aAndres Salomonint cs5535_gpio_set_irq(unsigned group, unsigned irq); 1791b912c1bca5c162e611384fe7d39c916e081701aAndres Salomonvoid cs5535_gpio_setup_event(unsigned offset, int pair, int pme); 1805f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon 18182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon/* MFGPTs */ 18282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 18382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_MAX_TIMERS 8 18482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_TIMER_ANY (-1) 18582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 18682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_DOMAIN_WORKING 1 18782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_DOMAIN_STANDBY 2 18882dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_DOMAIN_ANY (MFGPT_DOMAIN_WORKING | MFGPT_DOMAIN_STANDBY) 18982dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 19082dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_CMP1 0 19182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_CMP2 1 19282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 19382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_EVENT_IRQ 0 19482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_EVENT_NMI 1 19582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_EVENT_RESET 3 19682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 19782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_REG_CMP1 0 19882dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_REG_CMP2 2 19982dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_REG_COUNTER 4 20082dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_REG_SETUP 6 20182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 20282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_CNTEN (1 << 15) 20382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_CMP2 (1 << 14) 20482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_CMP1 (1 << 13) 20582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_SETUP (1 << 12) 20682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_STOPEN (1 << 11) 20782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_EXTEN (1 << 10) 20882dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_REVEN (1 << 5) 20982dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon#define MFGPT_SETUP_CLKSEL (1 << 4) 21082dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 21182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonstruct cs5535_mfgpt_timer; 21282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 21382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonextern uint16_t cs5535_mfgpt_read(struct cs5535_mfgpt_timer *timer, 21482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon uint16_t reg); 21582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonextern void cs5535_mfgpt_write(struct cs5535_mfgpt_timer *timer, uint16_t reg, 21682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon uint16_t value); 21782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 21882dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonextern int cs5535_mfgpt_toggle_event(struct cs5535_mfgpt_timer *timer, int cmp, 21982dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon int event, int enable); 22082dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonextern int cs5535_mfgpt_set_irq(struct cs5535_mfgpt_timer *timer, int cmp, 22182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon int *irq, int enable); 22282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonextern struct cs5535_mfgpt_timer *cs5535_mfgpt_alloc_timer(int timer, 22382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon int domain); 22482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonextern void cs5535_mfgpt_free_timer(struct cs5535_mfgpt_timer *timer); 22582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 22682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonstatic inline int cs5535_mfgpt_setup_irq(struct cs5535_mfgpt_timer *timer, 22782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon int cmp, int *irq) 22882dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon{ 22982dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon return cs5535_mfgpt_set_irq(timer, cmp, irq, 1); 23082dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon} 23182dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 23282dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomonstatic inline int cs5535_mfgpt_release_irq(struct cs5535_mfgpt_timer *timer, 23382dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon int cmp, int *irq) 23482dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon{ 23582dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon return cs5535_mfgpt_set_irq(timer, cmp, irq, 0); 23682dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon} 23782dca611bb516ec5fb7d04077733d6a4b70f52d1Andres Salomon 2385f0a96b044d8edaee20f4a32ef6c393599ca55f8Andres Salomon#endif 239