{"id":591,"date":"2019-09-27T18:37:47","date_gmt":"2019-09-27T10:37:47","guid":{"rendered":"http:\/\/iqotom.com\/?p=591"},"modified":"2019-09-27T18:37:50","modified_gmt":"2019-09-27T10:37:50","slug":"%e5%9c%a8x86-linux%e4%b8%ad%e9%85%8d%e7%bd%aesuperio-gpio%e5%af%84%e5%ad%98%e5%99%a8","status":"publish","type":"post","link":"https:\/\/iqotom.com\/?p=591","title":{"rendered":"\u5728X86 Linux\u4e2d\u914d\u7f6eSuperIO GPIO\u5bc4\u5b58\u5668"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Superio\u6982\u8ff0<\/h3>\n\n\n\n<p> Super I\/O\u82af\u7247\u4e5f\u53ebI\/O\u82af\u7247\u3002\u5728486\u4ee5\u4e0a\u6863\u6b21\u7684\u4e3b\u677f\u4e0a\u90fd\u6709I\/O\u63a7\u5236\u7535\u8def\u3002\u56e0\u4e3a\u5728\u5357\u6865\u8fd9\u6837\u7684\u9ad8\u901f\u8bbe\u5907\u548c\u4e32\u884c\u3001\u5e76\u884c\u63a5\u53e3\u3001\u8f6f\u76d8\u9a71\u52a8\u5668\u53ca\u952e\u76d8\u9f20\u6807\u7b49\u5927\u91cf\u4f4e\u901f\u8bbe\u5907\u4e4b\u95f4\u5fc5\u5b9a\u5b58\u5728\u8d44\u6e90\u7684\u4e0d\u5339\u914d\uff0c\u800c\u9700\u8981\u7ecf\u8fc7\u8f6c\u6362\u548c\u7ba1\u7406\u3002\u800cSuper I\/O\u82af\u7247\u5219\u5b8c\u6210\u4e86\u8be5\u529f\u80fd\u3002 <br> \u901a\u5e38\u5728\u786c\u4ef6\u76d1\u63a7\u82af\u7247\u786c\u4ef6\u76d1\u63a7\u82af\u7247\u4e2d\u4f1a\u6574\u5408\u8d85\u7ea7I\/O\u529f\u80fd\uff0c\u53ef\u7528\u4e8e\u76d1\u63a7\u53d7\u76d1\u63a7\u5bf9\u8c61\u7684\u7535\u538b\u3001\u6e29\u5ea6\u3001\u8f6c\u901f\u7b49\u3002\u4e3b\u677f\u5728\u9644\u4ef6\u4e2d\u4f1a\u63d0\u4f9b\u67d0\u79cd\u8f6f\u4ef6\uff0c\u5b83\u548c\u4e3b\u677f\u4e0a\u7684\u786c\u4ef6\u914d\u5408\u4f7f\u7528\u5c31\u80fd\u5b9e\u73b0\u5bf9\u7535\u538b\u3001\u6e29\u5ea6\u3001\u98ce\u6247\u8f6c\u901f\u7b49\u7684\u76d1\u63a7\uff0c\u4e00\u65e6\u68c0\u6d4b\u5230\u8fd9\u4e9b\u53c2\u6570\u8d85\u51fa\u8bbe\u5b9a\u7684\u6307\u6807\u65f6\uff0c\u5b83\u4f1a\u81ea\u52a8\u4f5c\u51fa\u8c03\u6574\uff0c\u4ee5\u4fdd\u62a4\u5143\u4ef6\u7684\u5b89\u5168\u3002 <br> \u4ee5\u4e0a\u5185\u5bb9\u5747\u4e3acopy\u81ea\u4e92\u8054\u7f51 \u3002<\/p>\n\n\n\n<p>\u7b14\u8005\u4f7f\u7528\u7684\u4e3b\u677f\u4e3a<strong><a href=\"http:\/\/www.qotom.com\/product\/92.html\">QOTOM Q4200UG2-P<\/a><\/strong>,SIO\u82af\u7247\u578b\u53f7\u4e3aIT8786E-I, \u9884\u7559\u7684GPIO\u7aef\u53e3\u4e3aGP80~GP87 <br>SuperIO\u82af\u7247\u5728\u4e3b\u677f\u7684\u5b9e\u7269\u56fe\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"627\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2019\/09\/SUPERIO-GPIO-01.jpg\" alt=\"\" class=\"wp-image-595\" srcset=\"https:\/\/iqotom.com\/wp-content\/uploads\/2019\/09\/SUPERIO-GPIO-01.jpg 1000w, https:\/\/iqotom.com\/wp-content\/uploads\/2019\/09\/SUPERIO-GPIO-01-300x188.jpg 300w, https:\/\/iqotom.com\/wp-content\/uploads\/2019\/09\/SUPERIO-GPIO-01-768x482.jpg 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><figcaption>IT8786E-I<\/figcaption><\/figure><\/div>\n\n\n\n<p> \u672c\u4eba\u5bf9SuperIO\u7684\u7406\u89e3\uff0c\u4e3b\u8981\u662f\u53c2\u8003linux\u5185\u6838\u4e2dgpio-it87\u9a71\u52a8\u4ee3\u7801\u548cgithub\u4e0a\u7684\u5176\u4ed6\u9879\u76ee\u6478\u7d22\u51fa\u6765\u7684\uff0c\u6587\u4e2d\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u9519\u8bef\uff01 \u8bf7\u5404\u4f4d\u5927\u795e\u6307\u6b63<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5927\u6982\u7684\u6d41\u7a0b\uff1a<\/h3>\n\n\n\n<p> <strong>\u4ee5\u4e0b\u7684\u6570\u636e\u90fd\u6765\u6e90\u4e8e\u82af\u7247\u624b\u518c\uff1a <\/strong><br> SuperIO\u63a7\u5236\u5668\u5730\u5740\u7aef\u53e3index=2Eh\uff0c\u6570\u636e\u7aef\u53e3index=2Fh(\u5b9e\u9645\u7684\u7269\u7406\u5185\u5b58\u5730\u5740)\uff1b <br> SuperIO\u82af\u7247\u529f\u80fd\u5165\u53e3\uff1a87h,01h,55h,55h\uff1b <br> GPIO LDN\u903b\u8f91\u8bbe\u5907\u53f7\uff1a07h\uff1b <br> GP80-GP87\uff1a\u5bc4\u5b58\u5668\u5730\u5740index=2Ch\uff0cDefault=89h\uff1b <br> GPIO Output\/Input Selection\uff1a index=CFh\uff1b <br> GPIO Simple I\/O Base Address MSB\/LSB Register\uff1aIndex=62h\/63h, Default=00h\uff1b <\/p>\n\n\n\n<ol><li> \u8fdb\u5165IO\u914d\u7f6e\u7a7a\u95f4 <\/li><li> \u8bbe\u7f6eIO\u5c5e\u6027 <\/li><li> \u8bbe\u7f6e\u8f93\u5165\u8f93\u51fa\u6a21\u5f0f <\/li><li> \u5f53IO\u8f93\u51fa\u65f6\u8bbe\u7f6e\u9ad8\u4f4e\u7535\u5e73 <\/li><li> \u9000\u51faIO\u914d\u7f6e\u7a7a\u95f4 <\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Linux \u5b9e\u73b0\u4ee3\u7801\uff1a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;stdio.h>\n#include&lt;sys\/io.h>\n#include&lt;stdlib.h>\n\n\/* IO Ports *\/\n#define REG\t\t0x2e\n#define VAL\t\t0x2f\n\/* Logical device Numbers *\/\n#define LDNREG\t\t0x07\n\/* GPIO Configuration Registers *\/\n#define GPIOLDN\t\t0x07\n\nstatic int superio_inw(int reg)\n{\n\tint val;\n\toutb(reg++, REG);\n\tval = inb(VAL) &lt;&lt; 8;\n\toutb(reg, REG);\n\tval |= inb(VAL);\n\treturn val;\n}\n\nint main(void)\n{   \n\tunsigned short int io_base;\n\n\t\/\/\u4fee\u6539\u7aef\u53e3\u6743\u9650\u4e3a\u53ef\u8bfb\u5199\n\tint ret = iopl(3);\n\tif(ret == -1)\n\t{\n\t\tprintf(\"iopl error.\\n\");\n\t\treturn -1;\n\t}\n\t\/\/\u8fdb\u5165IO\u914d\u7f6e\u7a7a\u95f4\n\toutb(0x87, REG);\n\toutb(0x01, REG);\n\toutb(0x55, REG);\n\toutb(0x55, REG);\n\t\/\/\u8bbe\u7f6eIO\u5c5e\u6027\n\toutb(LDNREG, REG);\n\toutb(GPIOLDN, VAL);\n\t\/\/Speecial Function Selection Register3(Index=2Ch, Default=89h)\n\toutb(0x2c, REG);\n\toutb(0x89, VAL);\n\n\t\/\/Simple I\/O Base Address MSB\/LSB Register index=62h\/63h\n\t\/\/\u83b7\u53d6GPIO\u57fa\u5730\u5740(16\u4f4d),\u9ad8\u4f4d0x62|\u4f4e\u4f4d0x63\u7ec4\u5408\u8d77\u6765\n\tio_base = superio_inw(0x62);\n\tprintf(\"gpio base addr:%02x\\n\", io_base);\n\n\t\/\/\u8bbe\u7f6e\u8f93\u5165\u8f93\u51fa\u6a21\u5f0fOutput\/Input Selection (Index CFh\uff09\n\t\/\/0xcf \u63a7\u5236GP80~87 \u4f5c\u4e3a\u8f93\u5165\u8fd8\u662f\u8f93\u51fa\n\toutb(0xcf, REG);\n\t\/\/bit0\u5bf9\u5e94GP80,bit1\u5bf9\u5e94GP81,\u4ee5\u6b64\u7c7b\u63a8\u3002\u4ee5\u4e0b\u662f\u628a\u6240\u6709IO\u4f5c\u4e3a\u8f93\u51fa\n\toutb(0xff, VAL);\n\n\t\/\/\u5f53IO\u4f5c\u4e3a\u8f93\u51fa\u65f6\uff0c\u62c9\u9ad8\u3001\u6216\u62c9\u4f4e\u8bbe\u7f6e\n\t\/\/\u4f7f\u7528\u7684\u7b2c8\u7ec4GPIO\uff0c\u8fd9\u91cc\u5730\u5740\u662f\u57fa\u5730\u5740+7\n\t\/\/\u63a7\u5236GP80~87\u8f93\u51fa\u9ad8\u8fd8\u662f\u4f4e,\u76f8\u5e94\u7684BIT \u8bbe\u4e3a0\u62c9\u4f4e\uff0c\u8bbe\u4e3a1\u62c9\u9ad8\n\t\/\/bit0\u5bf9\u5e94GP80,bit1\u5bf9\u5e94GP81,\u4ee5\u6b64\u7c7b\u63a8\u3002\u8fd9\u91cc\u6240\u6709IO\u8bbe\u7f6e\u4e3a\u9ad8\u7535\u5e73\n\toutb(0xff,io_base+7);\n\t\/\/\u8bbe\u7f6e\u5b8c\u540e\u9000\u51faIO\u914d\u7f6e\u7a7a\u95f4\n\toutb(0x02, REG);\n\toutb(0x02, VAL);\n\t\/\/\u6062\u590d\u7aef\u53e3\u6743\u9650\n\tiopl(0);\n\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<p> \u7f16\u8bd1\u540e\u6267\u884c\u9700\u8981root\u6743\u9650\uff0c\u53ef\u4ee5\u76f4\u63a5\u4e0aLED\u6d4b\u8bd5\uff0c\u4e0b\u56fe\u63a5\u7ebf\u662f\u4f4e\u7535\u5e73\u70b9\u4eae <\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"768\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2019\/09\/SUPERIO-GPIO-02-1024x768.jpg\" alt=\"\" class=\"wp-image-590\"\/><figcaption>\u6d4b\u8bd5\u7ed3\u679c\u6b63\u5e38<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u901a\u8fc7\u4e0a\u9762\u7684\u4ee3\u7801\u5c31\u53ef\u4ee5\u5728\u7528\u6237\u7a7a\u95f4\u76f4\u63a5\u64cd\u4f5cSuperIO GPIO \u7684\u5bc4\u5b58\u5668\u4e86\u3002<br>\u53e6\u5916\u8fd8\u5b9e\u73b0\u4e86\u4e00\u79cd\u65b9\u6cd5\uff0c\u76f4\u63a5\u5199\u6210\u9a71\u52a8\u7684\u65b9\u5f0f\uff0c\u521b\u5efa\u4e00\u4e2amisc\u8bbe\u5907\uff0c\u5b9e\u73b0ioctl\u51fd\u6570\uff0c\u5229\u7528ioctl\u901a\u4fe1\u5728\u7528\u6237\u7a7a\u95f4\u64cd\u4f5cGPIO\uff0c\u8fd9\u91cc\u5c31\u4e0d\u8d34\u4ee3\u7801\u4e86 <br> \u9879\u76ee\u6e90\u4ee3\u7801\uff1a<a href=\"https:\/\/github.com\/huchanghui123\/ITE-SuperIO.git\">https:\/\/github.com\/huchanghui123\/ITE-SuperIO.git<\/a> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Superio\u6982\u8ff0 Super I\/O\u82af\u7247\u4e5f\u53ebI\/O\u82af\u7247\u3002\u5728486\u4ee5\u4e0a\u6863\u6b21\u7684\u4e3b\u677f\u4e0a\u90fd\u6709I\/O\u63a7\u5236\u7535\u8def\u3002\u56e0\u4e3a\u5728\u5357\u2026 <span class=\"read-more\"><a href=\"https:\/\/iqotom.com\/?p=591\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":596,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,49],"tags":[47,53],"_links":{"self":[{"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/591"}],"collection":[{"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=591"}],"version-history":[{"count":3,"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/591\/revisions"}],"predecessor-version":[{"id":597,"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/591\/revisions\/597"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/media\/596"}],"wp:attachment":[{"href":"https:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}