Commit Graph

6 Commits

Author SHA1 Message Date
Gavin Shan 2d27b9fb3b rtc: gamecube: Always reset HW_SRNPROT after read
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183349

commit 509451ac03eb3afa4c4a32d4c11b1938f08de8e4
Author: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Date:   Tue Aug 23 15:07:02 2022 +0200

    rtc: gamecube: Always reset HW_SRNPROT after read

    This register would fail to be reset if reading the RTC bias failed for
    whichever reason.  This commit reorganises the code around to
    unconditionally write it back to its previous value, unmap it, and
    return the result of regmap_read(), which makes it both simpler and more
    correct in the error case.

    Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220823130702.1046-1-linkmauve@linkmauve.fr
    (cherry picked from commit 509451ac03eb3afa4c4a32d4c11b1938f08de8e4)

Signed-off-by: Gavin Shan <gshan@redhat.com>
2023-05-30 13:35:06 +10:00
Gavin Shan d28eaae2d7 rtc: gamecube: Add missing iounmap in gamecube_rtc_read_offset_from_sram
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183349

commit 6ddabcb106280db0f7344850adfce3dd6b171cbd
Author: Yuan Can <yuancan@huawei.com>
Date:   Wed May 11 07:13:54 2022 +0000

    rtc: gamecube: Add missing iounmap in gamecube_rtc_read_offset_from_sram

    The hw_srnprot needs to be unmapped when gamecube_rtc_read_offset_from_sram returns.

    Fixs: 86559400b3ef9d (rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U)
    Signed-off-by: Yuan Can <yuancan@huawei.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220511071354.46202-1-yuancan@huawei.com
    (cherry picked from commit 6ddabcb106280db0f7344850adfce3dd6b171cbd)

Signed-off-by: Gavin Shan <gshan@redhat.com>
2023-05-30 13:35:04 +10:00
Gavin Shan e9c01777fb rtc: gamecube: Fix refcount leak in gamecube_rtc_read_offset_from_sram
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183349

commit 4b2dc39ca024990abe36ad5d145c4fe0c06afd34
Author: Miaoqian Lin <linmq006@gmail.com>
Date:   Wed Mar 9 09:22:25 2022 +0000

    rtc: gamecube: Fix refcount leak in gamecube_rtc_read_offset_from_sram

    The of_find_compatible_node() function returns a node pointer with
    refcount incremented, We should use of_node_put() on it when done
    Add the missing of_node_put() to release the refcount.

    Fixes: 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220309092225.6930-1-linmq006@gmail.com
    (cherry picked from commit 4b2dc39ca024990abe36ad5d145c4fe0c06afd34)

Signed-off-by: Gavin Shan <gshan@redhat.com>
2023-05-30 13:35:03 +10:00
Gavin Shan 13e6644720 rtc: gamecube: Fix an IS_ERR() vs NULL check
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183349

commit 900ed72c8a190e8c0b87cb17abc645b8ec713011
Author: Dan Carpenter <dan.carpenter@oracle.com>
Date:   Fri Jan 7 10:33:40 2022 +0300

    rtc: gamecube: Fix an IS_ERR() vs NULL check

    The devm_kzalloc() function returns NULL on error, it doesn't return
    error pointers.

    Fixes: 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Reviewed-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220107073340.GF22086@kili
    (cherry picked from commit 900ed72c8a190e8c0b87cb17abc645b8ec713011)

Signed-off-by: Gavin Shan <gshan@redhat.com>
2023-05-30 13:35:01 +10:00
Gavin Shan 7b68dacb95 rtc: gamecube: Report low battery as invalid data
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183349

commit 322539a014bcd24cbb9281832c09b24e07912237
Author: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Date:   Wed Dec 15 18:54:58 2021 +0100

    rtc: gamecube: Report low battery as invalid data

    I haven’t been able to test this patch as all of my consoles have a
    working RTC battery, but according to the documentation it should work
    like that.

    Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
    Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20211215175501.6761-3-linkmauve@linkmauve.fr
    (cherry picked from commit 322539a014bcd24cbb9281832c09b24e07912237)

Signed-off-by: Gavin Shan <gshan@redhat.com>
2023-05-30 13:35:00 +10:00
Gavin Shan b25019e769 rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2183349

commit 86559400b3ef9de93ba50523cffe767c35cd531a
Author: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Date:   Wed Dec 15 18:54:57 2021 +0100

    rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U

    These three consoles share a device, the MX23L4005, which contains a
    clock and 64 bytes of SRAM storage, and is exposed on the EXI bus
    (similar to SPI) on channel 0, device 1.  This driver allows it to be
    used as a Linux RTC device, where time can be read and set.

    The hardware also exposes two timers, one which shuts down the console
    and one which powers it on, but these aren’t supported currently.

    On the Wii U, the counter bias is stored in a XML file, /config/rtc.xml,
    encrypted in the SLC (eMMC storage), using a proprietary filesystem.  In
    order to avoid having to implement all that, this driver assumes a
    bootloader will parse this XML file and write the bias into the SRAM, at
    the same location the other two consoles have it.

    Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
    Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20211215175501.6761-2-linkmauve@linkmauve.fr
    (cherry picked from commit 86559400b3ef9de93ba50523cffe767c35cd531a)

Signed-off-by: Gavin Shan <gshan@redhat.com>
2023-05-30 13:35:00 +10:00