|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 {: c- B1 a- `" J g$ t0 U
#include <linux/init.h>
0 W8 J8 r; S( k) u#include <linux/module.h>
9 m' E2 N$ \9 G" [9 f9 v#include <linux/kernel.h>
p5 F& l9 d* K2 c9 q* {7 @$ Y#include <linux/types.h>+ v8 g7 O/ ~/ G( t0 q
#include <linux/gpio.h>
5 J' V( {! x9 o/ T5 t8 T- p#include <linux/leds.h>" g. S; p# R/ w7 j) t4 x
#include <linux/platform_device.h>
% H" g8 x# D0 d- g8 L: Q8 ~: ^: ?: g
#include <asm/mach-types.h> _& U. V9 N- M+ c% [% s/ _6 [
#include <asm/mach/arch.h>! I' f9 I, ^+ {- L+ n
#include <mach/da8xx.h>
8 w' f/ }$ A2 `! @7 h2 U. @; @#include <mach/mux.h>7 @' S* K' q8 }0 @/ h
% A/ e2 y! g; V- C8 v! q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- y- d: N+ K, o) T2 M5 {6 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; H4 x# v3 l- Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ H3 F9 ?$ b* j8 E q0 ?+ l* ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. S3 h% o' z6 u2 x/ k
. n' E+ O/ a4 s* w% v, j/* assign the tl som board LED-GPIOs*/2 N" ^; S; R) ]# x+ v3 h
static const short da850_evm_tl_user_led_pins[] = {* P' s& ?7 y3 u) m% X b3 I
/* These pins are definition at <mach/mux.h> file */* N4 `0 b) z; E7 z' |( X( M4 y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! R# m6 M* O) o -1
9 ~8 E5 ]; s# Z' ^4 R' O' d7 `};+ [7 H/ T8 W+ K
9 R) y; H9 o. K6 _% U
static struct gpio_led da850_evm_tl_leds[] = {
" W7 c* I- a& k8 G9 h4 O {3 I% i+ K9 V' K0 K! C/ o
.active_low = 0,7 Z) z* b4 h% t
.gpio = DA850_USER_LED0,
\# r9 a' e6 r- H3 Q5 S .name = "user_led0",8 C$ ~5 P9 d9 D# y6 i- ]
.default_trigger = "default-on",
! A8 |! P% n& q8 U2 q; q7 n },
# _$ V) W7 v' d) n& J% f {4 E; \; A: j+ `1 q* R4 W; A% [2 k
.active_low = 0,/ h- V4 O, I$ J, ~1 O" Q
.gpio = DA850_USER_LED1,+ t: b! }; d4 l1 f- U! I, H F
.name = "user_led1",! x+ b6 H3 ]; m9 N J' I
.default_trigger = "default-on",
7 P0 H* G- d8 K. W# ` },
# v/ F* K" D0 V/ ? {
, _& ?; E7 A% F2 T, W" G, x# L .active_low = 0,. s: U9 K- F6 Y1 s' `
.gpio = DA850_USER_LED2,
/ A5 M7 C" t' Z3 ]9 `1 [ .name = "user_led2",5 s! j: H' A9 @
.default_trigger = "default-on",
! ?9 W0 Z" v2 ^0 b },* Q! \6 [( c# `# G6 K( G
{" C7 D) f z- }5 k6 h$ i) S
.active_low = 0,4 V7 v. A q3 g& O% i# Q* |7 I2 e4 n
.gpio = DA850_USER_LED3,! S5 i3 j6 X& l! O Y
.name = "user_led3",: T$ N2 W9 a. i# ^! j. L3 Z
.default_trigger = "default-on",
$ y# J8 C# d9 k k& e0 D },
: Z: u% F% e3 k};
& r; t$ q5 d& m$ r4 [/ V, ^ Q: X2 r$ F1 g [9 o7 w, P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 W% C6 |0 u' t2 T
.leds = da850_evm_tl_leds,
. w) j2 {3 r% b& D8 T& m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! w! J# U2 e' s* w; f};5 D% ~- P( s! X! \- I
. X& F6 Q1 L5 V! \9 v' W1 [3 ?( \
static void led_dev_release(struct device *dev)
/ J: n( \" Y) e: @$ Q5 C{- q* D/ C( t7 _5 B2 w+ \# W
};
F" I5 s, w2 e& m5 G' w- n h1 q4 V
static struct platform_device da850_evm_tl_leds_device = {
9 P( O1 d2 `- P% S4 y# v .name = "leds-gpio",
t+ ^, P. R7 U$ ? .id = 1,
1 ^; t( F- ^5 L3 d* U: m .dev = {
, M/ \8 a9 H9 t! z .platform_data = &da850_evm_tl_leds_pdata,
4 @) u. k0 c+ K1 t1 P/ C! S/ \2 ]. l .release = led_dev_release,, O5 W9 s3 T$ M
}
" V3 \& ^( E4 r5 h8 T8 B _: z& T O};8 H4 u+ ]0 |- W0 V; \
7 ]3 w# X2 m4 C* P; mstatic int __init led_platform_init(void)+ V" W* l) \' C, L/ |
{4 k5 `9 }, r+ u3 A
int ret;
$ n2 d- u1 J0 Y#if 0
7 A# q1 o6 C# {1 o; d& j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 ]3 B0 o6 o" W. e5 v$ E% ^) Y- b4 P5 k
if (ret)
- b. Z. y: c, M$ ]4 U; f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& j: [! [3 H D/ I/ q3 l5 v "%d\n", ret);
9 j, j0 g# E4 t9 o#endif
$ \2 c0 F d2 o! q; p, u3 I3 r4 m ret = platform_device_register(&da850_evm_tl_leds_device);
8 d" O( ?- s% i/ m! | if (ret)
/ Q, A3 ~$ W/ [. b% L3 x' L! C pr_warning("Could not register som GPIO expander LEDS");3 l, v! b. H7 d8 e
else; w/ @) ^' Y" s
printk(KERN_INFO "LED register sucessful!\n");8 g2 e* g' R. {
( u, B, G- a; R- I5 U
return ret;
% [! w9 @, h& e0 V9 X8 |}7 h4 H; {5 Y3 U+ Y
* Y5 }% Q) I1 h% q) k9 [# n* `
static void __exit led_platform_exit(void)# V f; m+ u2 l
{; _0 {0 O8 F9 F0 z
platform_device_unregister(&da850_evm_tl_leds_device);3 |+ q( I8 c; W2 U& X
' o) ^4 w3 |# B) W( D" j) p0 R printk(KERN_INFO "LED unregister!\n");
7 @/ q/ e" G' p1 V}2 @" g1 q" g- K# I# M \
1 B# A1 o' b# e& T
module_init(led_platform_init); R0 ?. C$ K, v& b3 Z% Y
module_exit(led_platform_exit);
/ c3 T* ^ u- e& i; j- P
+ ^' v1 u0 g6 q8 U0 tMODULE_DESCRIPTION("Led platform driver");
. h/ M0 V. e* MMODULE_AUTHOR("Tronlong");4 S' q2 q# c. M
MODULE_LICENSE("GPL");
. b# u& z) v: T1 L J* o
S. g, K: l5 w |
|