|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 k) {# G! A( K# y" G9 W1 j#include <linux/init.h>2 h5 j7 H) e ~
#include <linux/module.h>" O9 [" F- s/ k% o: w; x8 m$ c. ?* e$ n
#include <linux/kernel.h>
' I3 [- Y$ E. m1 M# W7 i#include <linux/types.h># H8 W4 v+ Z2 o( N; {
#include <linux/gpio.h>8 n" j" o" {/ _" k6 x- g+ {
#include <linux/leds.h>5 C# F* j9 N# Q! R
#include <linux/platform_device.h>$ b2 O/ k% L7 u, L
7 D( \) B: W& U6 _
#include <asm/mach-types.h>
) r4 q& a$ p. x4 W# M" N v. u#include <asm/mach/arch.h>+ Z3 W4 v( ~$ d9 F
#include <mach/da8xx.h>* i2 M5 Q% q! p' Y7 L
#include <mach/mux.h>
6 J, W7 {4 B$ a4 f9 M9 R0 H' {- v9 G1 g/ y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; P. \, {' ~- C$ |' z9 c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ N. g W3 P- {8 \: o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! P1 v) @+ K7 }' T; A! }* R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' q1 S2 H+ d; {; v6 \6 y6 m" W
h# X( ^$ M" y
/* assign the tl som board LED-GPIOs*/2 Y. W' k+ l5 Z' C
static const short da850_evm_tl_user_led_pins[] = {
4 e! M% b6 y% T# U# @ /* These pins are definition at <mach/mux.h> file */
$ k. _& [1 v- h7 x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" x X: t. F7 V6 A -1
! z0 B3 R+ R* F' Q1 h2 A};
. P$ l3 G$ G# i2 p! m- o3 B0 i+ }' h$ O4 a4 N5 w/ X
static struct gpio_led da850_evm_tl_leds[] = {
8 [+ L& ~# ~: l" K0 C! M X {
0 A+ l8 @ O% n5 }8 i% t .active_low = 0,
& m) W/ H1 W- ^) r# K; H. y .gpio = DA850_USER_LED0,( K/ g, z0 A2 y$ z& P1 C" J, O
.name = "user_led0",0 H# \) i* v8 E- z5 X& p" A
.default_trigger = "default-on",/ V- h% z1 q# C, t% _: h
},
! T# D- f8 I' a v+ n" K$ X$ X% Q' O {
* z$ f% ~ ?5 c .active_low = 0,
; C6 D: [! ?3 g5 V6 A" F. P7 S .gpio = DA850_USER_LED1,/ z& [/ {3 ] ^' [ C5 {
.name = "user_led1",
1 o: w3 `( T) T S y/ L .default_trigger = "default-on", e" `+ m m- ^' X3 W2 ?
},
. R0 u- O Q$ E2 K6 Q o% x3 `* { {6 A: H% R8 I; l6 q+ t
.active_low = 0,
/ z6 O0 [, S4 @( l4 Y .gpio = DA850_USER_LED2,+ X" l" Q2 f& \( \6 B! }, k# b
.name = "user_led2",* Q, F4 E3 R) h; I) R. x
.default_trigger = "default-on",2 R3 ~+ |* B2 A
},1 t E3 N' l6 q/ c; ^# ^8 B
{& @* e. y$ Y! w- v! P% {
.active_low = 0,
6 s: T6 d. H1 Q2 v* I .gpio = DA850_USER_LED3,
- ]5 j0 I/ L& I$ e& q .name = "user_led3",' \6 N' k1 h& ~9 n3 |
.default_trigger = "default-on",
( Q6 v4 {& {- u' c },
, ~; x) f" T; s# \. n};) V: U* f2 t- P9 w4 V
1 v/ _; D7 ] C1 L4 ^! }) s; [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ b8 L4 ?8 W$ F( Z .leds = da850_evm_tl_leds,2 N" F* X; K1 e) L+ D/ J* T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- a Z) L) Z/ d};% q' X' o3 u: t$ M0 x
% U1 r+ P& J; S# U% I' lstatic void led_dev_release(struct device *dev)! O8 E& |4 d* U* l8 Y' h) F
{
I; T9 R. {9 z( n% P. |9 v};/ B" s% m0 K. a2 k, C
* `# _6 j5 s/ w5 N \static struct platform_device da850_evm_tl_leds_device = {! a5 [9 g5 K- F
.name = "leds-gpio",( d# Y( v- N, ?% J# B+ n
.id = 1,- {' o, j9 @7 v7 I: j
.dev = {
/ h" @* e1 c3 y0 ]8 p) v% T0 n .platform_data = &da850_evm_tl_leds_pdata,1 y F6 |4 G8 N) z
.release = led_dev_release,, D! H5 y( c/ ]1 V* `
}
% r9 C7 P# I+ J# s};
; y: E$ r9 [& t: w/ m! D+ o# t* J5 h& {8 ]8 Q( w
static int __init led_platform_init(void)
- E$ q" d0 m' P{1 ~8 _8 N% g+ n" ~
int ret;
7 e9 h$ {: Q$ u; E#if 07 X5 L1 F* V& |8 v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, U! N2 h- G9 Y% q9 \0 R" L& C3 @9 _ if (ret)
* Y( x8 s: ?. D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, f7 Z% A% b# O$ [# U" X "%d\n", ret);2 T# x! ^0 J' _9 }, g
#endif
- C8 O" s; w; i0 I ret = platform_device_register(&da850_evm_tl_leds_device);8 X$ x# j: y3 k% M5 d/ R- o
if (ret). k' p- w. D" n" }
pr_warning("Could not register som GPIO expander LEDS");) `: B- a1 |8 ~/ s* ~
else7 h2 C8 O9 b5 S" y
printk(KERN_INFO "LED register sucessful!\n");
! W& M- `/ p. z$ t2 h
. K {" ~/ P- u( {; Z L2 b return ret;: x+ z1 f, _$ k# R$ t8 _: a
}% n' u" b- d2 C q( D; Z/ P4 R/ Z
7 V4 E* M0 |6 p, E9 S7 ^
static void __exit led_platform_exit(void)% h: |' J9 X$ _* M, C& o5 G
{
9 j, Y( V3 e6 |4 W platform_device_unregister(&da850_evm_tl_leds_device);2 a" N; c n+ B# F/ X
8 k. f6 H+ W; _9 K& I$ U: U printk(KERN_INFO "LED unregister!\n");# a, G+ J% K3 c, l7 P% b
}8 i2 o$ R2 Z2 k! ]) o O
5 s8 a& K( t6 ~# m
module_init(led_platform_init);
# M# a# D" w2 a. q0 w# Y" omodule_exit(led_platform_exit);" r: K7 J8 W8 |, e2 t
! x6 p2 T7 B( Q
MODULE_DESCRIPTION("Led platform driver");
0 S( Y# o8 {, Z5 m( uMODULE_AUTHOR("Tronlong");
& d$ X( e; k. X* ]( G* ZMODULE_LICENSE("GPL");! y- c. D8 w, j& V& {3 c
/ V* ?5 g2 _ m2 F
|
|