From 1ab63c3d9251233e8c4b415c1ab9d6741c3c90ae Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Wed, 1 Oct 2025 20:45:07 -0400 Subject: [PATCH] ipod: Small cleanup of piezo code on PP502x-based iPods Basically use proper register names instead of magic values. PP5002-based ipods (ie ipod1g-3g) use UART1 to drive the piezo vs PWM of the newer models. Change-Id: Ia333717a825ac6a0ebf43850fc31fca34178dd88 --- firmware/SOURCES | 8 ++++---- firmware/export/pp5020.h | 7 +++++-- firmware/target/arm/ipod/piezo.c | 8 ++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/firmware/SOURCES b/firmware/SOURCES index 2b88a434d9..19d7fa1bba 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -658,13 +658,13 @@ target/arm/ipod/power-ipod.c # if LCD_DEPTH == 2 target/arm/ipod/lcd-as-gray.S # endif -# ifndef IPOD_1G2G -# ifndef IPOD_3G +# if defined(CPU_PP502x) target/arm/ipod/piezo.c -# endif /* IPOD_3G */ +# endif /* CPU_PP502x */ +# ifndef IPOD_1G2G drivers/pcf50605.c target/arm/ipod/powermgmt-ipod-pcf.c -# endif /* IPOD_1G2G */ +# endif /* !IPOD_1G2G */ #endif /* CPU_PP && IPOD_ARCH */ #if CONFIG_I2C == I2C_PP5024 || CONFIG_I2C == I2C_PP5020 || CONFIG_I2C == I2C_PP5002 diff --git a/firmware/export/pp5020.h b/firmware/export/pp5020.h index 0d2ffc4d94..cd7cc80d66 100644 --- a/firmware/export/pp5020.h +++ b/firmware/export/pp5020.h @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2004 by Thom Johansen + * Copyright (C) 2004 by Thom Johansen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -96,7 +96,7 @@ #define CPU_HI_INT_EN (*(volatile unsigned long*)(0x60004124)) #define CPU_HI_INT_DIS (*(volatile unsigned long*)(0x60004128)) #define CPU_HI_INT_PRIORITY (*(volatile unsigned long*)(0x6000412c)) - + #define COP_HI_INT_EN_STAT (*(volatile unsigned long*)(0x60004130)) #define COP_HI_INT_EN (*(volatile unsigned long*)(0x60004134)) #define COP_HI_INT_DIS (*(volatile unsigned long*)(0x60004138)) @@ -551,6 +551,9 @@ #define LCD2_BLOCK_READY 0x04000000 #define LCD2_BLOCK_TXOK 0x01000000 +/* PWM */ +#define PWM0_CTRL (*(volatile unsigned long*)(0x7000a000)) + /* I2C */ #define I2C_BASE 0x7000c000 diff --git a/firmware/target/arm/ipod/piezo.c b/firmware/target/arm/ipod/piezo.c index 2b77c35309..898f12dd24 100644 --- a/firmware/target/arm/ipod/piezo.c +++ b/firmware/target/arm/ipod/piezo.c @@ -43,22 +43,22 @@ static inline void piezo_hw_init(void) { #ifndef SIMULATOR /*logf("PIEZO: hw_init");*/ - outl(inl(0x70000010) & ~0xc, 0x70000010); - outl(inl(0x6000600c) | 0x20000, 0x6000600c); /* enable device */ + DEV_INIT1 &= ~0xc; + DEV_EN |= DEV_PWM; #endif } static void piezo_hw_tick(unsigned int form_and_period) { #ifndef SIMULATOR - outl(0x80000000 | form_and_period, 0x7000a000); /* set pitch */ + PWM0_CTRL = 0x80000000 | form_and_period; #endif } static inline void piezo_hw_stop(void) { #ifndef SIMULATOR - outl(0x0, 0x7000a000); /* piezo off */ + PWM0_CTRL = 0; #endif }