get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/655/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 655,
    "url": "http://patchwork.ozlabs.org/api/patches/655/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20080919180354.GB13899@oksana.dev.rtsoft.ru/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<20080919180354.GB13899@oksana.dev.rtsoft.ru>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20080919180354.GB13899@oksana.dev.rtsoft.ru/",
    "date": "2008-09-19T18:03:54",
    "name": "[2/2] i2c: MPC8349E-mITX Power Management and GPIO expander driver",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "fde8400015a9be36121b9dc222f04e3832edd42a",
    "submitter": {
        "id": 45,
        "url": "http://patchwork.ozlabs.org/api/people/45/?format=api",
        "name": "Anton Vorontsov",
        "email": "avorontsov@ru.mvista.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20080919180354.GB13899@oksana.dev.rtsoft.ru/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/655/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/655/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org>",
        "X-Original-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@ozlabs.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@ozlabs.org"
        ],
        "Received": [
            "from ozlabs.org (localhost [127.0.0.1])\n\tby ozlabs.org (Postfix) with ESMTP id 94CBBDE4E3\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 20 Sep 2008 04:04:15 +1000 (EST)",
            "from buildserver.ru.mvista.com (unknown [85.21.88.6])\n\tby ozlabs.org (Postfix) with ESMTP id 60244DE399\n\tfor <linuxppc-dev@ozlabs.org>; Sat, 20 Sep 2008 04:03:58 +1000 (EST)",
            "from localhost (unknown [10.150.0.9])\n\tby buildserver.ru.mvista.com (Postfix) with ESMTP\n\tid A816D8823; Fri, 19 Sep 2008 23:03:54 +0500 (SAMST)"
        ],
        "Date": "Fri, 19 Sep 2008 22:03:54 +0400",
        "From": "Anton Vorontsov <avorontsov@ru.mvista.com>",
        "To": "Jean Delvare <khali@linux-fr.org>,\n\tBen Dooks <ben-linux@fluff.org>",
        "Subject": "[PATCH 2/2] i2c: MPC8349E-mITX Power Management and GPIO expander\n\tdriver",
        "Message-ID": "<20080919180354.GB13899@oksana.dev.rtsoft.ru>",
        "MIME-Version": "1.0",
        "Content-Disposition": "inline",
        "User-Agent": "Mutt/1.5.18 (2008-05-17)",
        "Cc": "linuxppc-dev@ozlabs.org, i2c@lm-sensors.org",
        "X-BeenThere": "linuxppc-dev@ozlabs.org",
        "X-Mailman-Version": "2.1.11",
        "Precedence": "list",
        "List-Id": "Linux on PowerPC Developers Mail List <linuxppc-dev.ozlabs.org>",
        "List-Unsubscribe": "<https://ozlabs.org/mailman/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@ozlabs.org?subject=unsubscribe>",
        "List-Archive": "<http://ozlabs.org/pipermail/linuxppc-dev>",
        "List-Post": "<mailto:linuxppc-dev@ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev-request@ozlabs.org?subject=help>",
        "List-Subscribe": "<https://ozlabs.org/mailman/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@ozlabs.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org",
        "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org"
    },
    "content": "On MPC8349E-mITX, MPC8315E-RDB and MPC837x-RDB boards there is a\nFreescale MC9S08QG8 (MCU) chip with the custom firmware\npre-programmed. The chip is used to power-off the board by the\nsoftware, and to control some GPIO pins.\n\nSigned-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>",
    "diff": "diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig\nindex a95cb94..1735682 100644\n--- a/drivers/i2c/chips/Kconfig\n+++ b/drivers/i2c/chips/Kconfig\n@@ -172,4 +172,15 @@ config MENELAUS\n \t  and other features that are often used in portable devices like\n \t  cell phones and PDAs.\n \n+config MCU_MPC8349EMITX\n+\ttristate \"MPC8349E-mITX MCU driver\"\n+\tdepends on I2C && PPC_83xx\n+\tselect GENERIC_GPIO\n+\tselect ARCH_REQUIRE_GPIOLIB\n+\thelp\n+\t  Say Y here to enable soft power-off functionality on the Freescale\n+\t  boards with the MPC8349E-mITX-compatible MCU chips. This driver will\n+\t  also register MCU GPIOs with the generic GPIO API, so you'll able\n+\t  to use MCU pins as GPIOs.\n+\n endmenu\ndiff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile\nindex 39e3e69..ca520fa 100644\n--- a/drivers/i2c/chips/Makefile\n+++ b/drivers/i2c/chips/Makefile\n@@ -21,6 +21,7 @@ obj-$(CONFIG_ISP1301_OMAP)\t+= isp1301_omap.o\n obj-$(CONFIG_TPS65010)\t\t+= tps65010.o\n obj-$(CONFIG_MENELAUS)\t\t+= menelaus.o\n obj-$(CONFIG_SENSORS_TSL2550)\t+= tsl2550.o\n+obj-$(CONFIG_MCU_MPC8349EMITX)\t+= mcu_mpc8349emitx.o\n \n ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)\n EXTRA_CFLAGS += -DDEBUG\ndiff --git a/drivers/i2c/chips/mcu_mpc8349emitx.c b/drivers/i2c/chips/mcu_mpc8349emitx.c\nnew file mode 100644\nindex 0000000..47b07b8\n--- /dev/null\n+++ b/drivers/i2c/chips/mcu_mpc8349emitx.c\n@@ -0,0 +1,213 @@\n+/*\n+ * Power Management and GPIO expander driver for MPC8349E-mITX-compatible MCU\n+ *\n+ * Copyright (c) 2008  MontaVista Software, Inc.\n+ *\n+ * Author: Anton Vorontsov <avorontsov@ru.mvista.com>\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ */\n+\n+#include <linux/init.h>\n+#include <linux/kernel.h>\n+#include <linux/module.h>\n+#include <linux/device.h>\n+#include <linux/mutex.h>\n+#include <linux/i2c.h>\n+#include <linux/gpio.h>\n+#include <linux/of.h>\n+#include <linux/of_gpio.h>\n+#include <asm/prom.h>\n+#include <asm/machdep.h>\n+\n+/*\n+ * I don't have specifications for the MCU firmware, I found this register\n+ * and bits positions by the trial&error method.\n+ */\n+#define MCU_REG_CTRL\t0x20\n+#define MCU_CTRL_POFF\t0x40\n+\n+#define MCU_NUM_GPIO\t2\n+\n+struct mcu {\n+\tstruct mutex lock;\n+\tstruct device_node *np;\n+\tstruct i2c_client *client;\n+\tstruct of_gpio_chip of_gc;\n+\tu8 reg_ctrl;\n+};\n+\n+static struct mcu *glob_mcu;\n+\n+static void mcu_power_off(void)\n+{\n+\tstruct mcu *mcu = glob_mcu;\n+\n+\tpr_info(\"Sending power-off request to the MCU...\\n\");\n+\tmutex_lock(&mcu->lock);\n+\ti2c_smbus_write_byte_data(glob_mcu->client, MCU_REG_CTRL,\n+\t\t\t\t  mcu->reg_ctrl | MCU_CTRL_POFF);\n+\tmutex_unlock(&mcu->lock);\n+}\n+\n+static void mcu_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val)\n+{\n+\tstruct of_gpio_chip *of_gc = to_of_gpio_chip(gc);\n+\tstruct mcu *mcu = container_of(of_gc, struct mcu, of_gc);\n+\tu8 bit = 1 << (4 + gpio);\n+\n+\tmutex_lock(&mcu->lock);\n+\tif (val)\n+\t\tmcu->reg_ctrl &= ~bit;\n+\telse\n+\t\tmcu->reg_ctrl |= bit;\n+\n+\ti2c_smbus_write_byte_data(mcu->client, MCU_REG_CTRL, mcu->reg_ctrl);\n+\tmutex_unlock(&mcu->lock);\n+}\n+\n+static int mcu_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)\n+{\n+\tmcu_gpio_set(gc, gpio, val);\n+\treturn 0;\n+}\n+\n+static int mcu_gpiochip_add(struct mcu *mcu)\n+{\n+\tstruct device_node *np;\n+\tstruct of_gpio_chip *of_gc = &mcu->of_gc;\n+\tstruct gpio_chip *gc = &of_gc->gc;\n+\tint ret;\n+\n+\tnp = of_find_compatible_node(NULL, NULL, \"fsl,mcu-mpc8349emitx\");\n+\tif (!np)\n+\t\treturn -ENODEV;\n+\n+\tgc->owner = THIS_MODULE;\n+\tgc->label = np->full_name;\n+\tgc->can_sleep = 1;\n+\tgc->ngpio = MCU_NUM_GPIO;\n+\tgc->base = -1;\n+\tgc->set = mcu_gpio_set;\n+\tgc->direction_output = mcu_gpio_dir_out;\n+\tof_gc->gpio_cells = 2;\n+\tof_gc->xlate = of_gpio_simple_xlate;\n+\n+\tnp->data = of_gc;\n+\tmcu->np = np;\n+\n+\t/*\n+\t * We don't want to lose the node, its ->data and ->full_name...\n+\t * So, if succeeded, we don't put the node here.\n+\t */\n+\tret = gpiochip_add(gc);\n+\tif (ret)\n+\t\tof_node_put(np);\n+\treturn ret;\n+}\n+\n+static int mcu_gpiochip_remove(struct mcu *mcu)\n+{\n+\tint ret;\n+\n+\tret = gpiochip_remove(&mcu->of_gc.gc);\n+\tif (ret)\n+\t\treturn ret;\n+\tof_node_put(mcu->np);\n+\n+\treturn 0;\n+}\n+\n+static int __devinit mcu_probe(struct i2c_client *client,\n+\t\t\t       const struct i2c_device_id *id)\n+{\n+\tstruct mcu *mcu;\n+\tint ret;\n+\n+\tmcu = kzalloc(sizeof(*mcu), GFP_KERNEL);\n+\tif (!mcu)\n+\t\treturn -ENOMEM;\n+\n+\tmutex_init(&mcu->lock);\n+\tmcu->client = client;\n+\ti2c_set_clientdata(client, mcu);\n+\n+\tret = i2c_smbus_read_byte_data(mcu->client, MCU_REG_CTRL);\n+\tif (ret < 0)\n+\t\tgoto err;\n+\tmcu->reg_ctrl = ret;\n+\n+\tret = mcu_gpiochip_add(mcu);\n+\tif (ret)\n+\t\tgoto err;\n+\n+\t/* XXX: this is potentially racy, but there is no lock for ppc_md */\n+\tif (!ppc_md.power_off) {\n+\t\tglob_mcu = mcu;\n+\t\tppc_md.power_off = mcu_power_off;\n+\t\tdev_info(&client->dev, \"will provide power-off service\\n\");\n+\t}\n+\n+\treturn 0;\n+err:\n+\tkfree(mcu);\n+\treturn ret;\n+}\n+\n+static int __devexit mcu_remove(struct i2c_client *client)\n+{\n+\tstruct mcu *mcu = i2c_get_clientdata(client);\n+\tint ret;\n+\n+\tif (glob_mcu == mcu) {\n+\t\tppc_md.power_off = NULL;\n+\t\tglob_mcu = NULL;\n+\t}\n+\n+\tret = mcu_gpiochip_remove(mcu);\n+\tif (ret)\n+\t\treturn ret;\n+\ti2c_set_clientdata(client, NULL);\n+\tkfree(mcu);\n+\treturn 0;\n+}\n+\n+static const struct i2c_device_id mcu_ids[] = {\n+\t{ \"mc9s08qg8-mpc8349emitx\", },\n+\t{ \"mc9s08qg8-mpc8377rdb\", },\n+\t{ \"mc9s08qg8-mpc8378rdb\", },\n+\t{ \"mc9s08qg8-mpc8379rdb\", },\n+\t{ \"mc9s08qg8-mpc8315rdb\", },\n+\t{},\n+};\n+MODULE_DEVICE_TABLE(i2c, mcu_ids);\n+\n+static struct i2c_driver mcu_driver = {\n+\t.driver = {\n+\t\t.name = \"mcu-mpc8349emitx\",\n+\t\t.owner = THIS_MODULE,\n+\t},\n+\t.probe = mcu_probe,\n+\t.remove\t= __devexit_p(mcu_remove),\n+\t.id_table = mcu_ids,\n+};\n+\n+static int __init mcu_init(void)\n+{\n+\treturn i2c_add_driver(&mcu_driver);\n+}\n+module_init(mcu_init);\n+\n+static void __exit mcu_exit(void)\n+{\n+\ti2c_del_driver(&mcu_driver);\n+}\n+module_exit(mcu_exit);\n+\n+MODULE_DESCRIPTION(\"Power Management and GPIO expander driver for \"\n+\t\t   \"MPC8349E-mITX-compatible MCU\");\n+MODULE_AUTHOR(\"Anton Vorontsov <avorontsov@ru.mvista.com>\");\n+MODULE_LICENSE(\"GPL\");\n",
    "prefixes": [
        "2/2"
    ]
}